added filter sold

This commit is contained in:
vedatakd 2021-07-30 17:04:09 +03:00
parent 9be8a7586b
commit c96801e093
5 changed files with 39 additions and 3 deletions

View File

@ -98,7 +98,7 @@ return [
'title' => 'visiosoft.module.advs::section.filter',
'fields' => [
'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' => [

View File

@ -479,5 +479,11 @@ return [
'config' => [
'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' => [
'name' => 'Show Flags on Input',
'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

@ -395,6 +395,15 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
$latest_advs = $this->model->currentAds()
->limit(setting_value('visiosoft.module.advs::latest-limit'))
->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);
}

View File

@ -240,6 +240,14 @@ class AdvsController extends PublicController
), 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) {
$advs[$index]->detail_url = $this->adv_model->getAdvDetailLinkByModel($ad, 'list');
$advs[$index] = $this->adv_model->AddAdsDefaultCoverImage($ad);
@ -1096,6 +1104,15 @@ class AdvsController extends PublicController
$advModel = new AdvModel();
$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) {
$advs[$index]->seo_link = $advModel->getAdvDetailLinkByModel($ad, 'list');
$advs[$index] = $advModel->AddAdsDefaultCoverImage($ad);