Merge pull request #1129 from openclassify/vedat

added filter sold
This commit is contained in:
Dia Shalabi 2021-08-02 16:10:25 +03:00 committed by GitHub
commit 709bb4d8e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 4 deletions

View File

@ -98,7 +98,7 @@ return [
'title' => 'visiosoft.module.advs::section.filter', 'title' => 'visiosoft.module.advs::section.filter',
'fields' => [ 'fields' => [
'hide_filter_section', 'hide_price_filter', 'hide_date_filter', 'hide_photo_filter', 'hide_map_filter', 'hide_filter_section', 'hide_price_filter', 'hide_date_filter', 'hide_photo_filter', 'hide_map_filter',
'hide_listing_header', 'user_filter_limit', 'hide_listing_header', 'user_filter_limit','hide_out_of_stock_products_without_listing'
], ],
], ],
'translations' => [ 'translations' => [

View File

@ -479,5 +479,11 @@ return [
'config' => [ 'config' => [
'default_value' => false, 'default_value' => false,
] ]
] ],
'hide_out_of_stock_products_without_listing' => [
'type' => 'anomaly.field_type.boolean',
'config' => [
'default_value' => false,
]
],
]; ];

View File

@ -286,5 +286,9 @@ return [
'show_input_flag' => [ 'show_input_flag' => [
'name' => 'Show Flags on Input', 'name' => 'Show Flags on Input',
'instructions' => 'Show flag and description on translatable inputs' 'instructions' => 'Show flag and description on translatable inputs'
] ],
'hide_out_of_stock_products_without_listing' => [
'name' => 'Hide out of stock products without listing',
'instructions' => 'Hides out-of-stock GET products from listing and homepage'
],
]; ];

View File

@ -34,7 +34,7 @@
<td> <td>
<a href="{{ adv.detail_url }}"> <a href="{{ adv.detail_url }}">
<img src="{{ img('visiosoft.theme.base::images/no-image.png').url }}" class="rounded lazy" <img src="{{ img('visiosoft.theme.base::images/no-image.png').url }}" class="rounded lazy"
alt="{{ adv.name }}" data-src="{{ adv.cover_photo }}"> alt="{{ adv.name }}" data-src="{{ adv.thumbnail }}">
</a> </a>
</td> </td>
<td class="text-left pl-2"> <td class="text-left pl-2">

View File

@ -395,6 +395,15 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
$latest_advs = $this->model->currentAds() $latest_advs = $this->model->currentAds()
->limit(setting_value('visiosoft.module.advs::latest-limit')) ->limit(setting_value('visiosoft.module.advs::latest-limit'))
->get(); ->get();
if (setting_value('visiosoft.module.advs::hide_out_of_stock_products_without_listing')) {
$latest_advs = $latest_advs->filter(
function ($entry) {
return (($entry->is_get_adv == true && $entry->stock > 0) || ($entry->is_get_adv == false));
}
);
}
return $this->model->getLocationNames($latest_advs); return $this->model->getLocationNames($latest_advs);
} }

View File

@ -240,6 +240,14 @@ class AdvsController extends PublicController
), 301); ), 301);
} }
if (setting_value('visiosoft.module.advs::hide_out_of_stock_products_without_listing')) {
$advs = $advs->filter(
function ($entry) {
return (($entry->is_get_adv == true && $entry->stock > 0) || ($entry->is_get_adv == false));
}
);
}
foreach ($advs as $index => $ad) { foreach ($advs as $index => $ad) {
$advs[$index]->detail_url = $this->adv_model->getAdvDetailLinkByModel($ad, 'list'); $advs[$index]->detail_url = $this->adv_model->getAdvDetailLinkByModel($ad, 'list');
$advs[$index] = $this->adv_model->AddAdsDefaultCoverImage($ad); $advs[$index] = $this->adv_model->AddAdsDefaultCoverImage($ad);
@ -1096,6 +1104,15 @@ class AdvsController extends PublicController
$advModel = new AdvModel(); $advModel = new AdvModel();
$advs = $repository->searchAdvs('map', $param, $customParameters); $advs = $repository->searchAdvs('map', $param, $customParameters);
if (setting_value('visiosoft.module.advs::hide_out_of_stock_products_without_listing')) {
$advs = $advs->filter(
function ($entry) {
return (($entry->is_get_adv == true && $entry->stock > 0) || ($entry->is_get_adv == false));
}
);
}
foreach ($advs as $index => $ad) { foreach ($advs as $index => $ad) {
$advs[$index]->seo_link = $advModel->getAdvDetailLinkByModel($ad, 'list'); $advs[$index]->seo_link = $advModel->getAdvDetailLinkByModel($ad, 'list');
$advs[$index] = $advModel->AddAdsDefaultCoverImage($ad); $advs[$index] = $advModel->AddAdsDefaultCoverImage($ad);