Skip to content

Commit

Permalink
Implemented the show out of stock option
Browse files Browse the repository at this point in the history
  • Loading branch information
royduin committed Jan 8, 2022
1 parent 6db9fe6 commit 67b1e5e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Models/Scopes/RelatedProductsScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ class RelatedProductsScope implements Scope
{
public function apply(Builder $builder, Model $model)
{
$builder->selectRaw('GROUP_CONCAT(related.entity_id) as amasty_related_ids')
$builder->selectRaw('GROUP_CONCAT(IF(amasty_mostviewed_group.show_out_of_stock = 0 AND related_stock.is_in_stock = 0, NULL, related.entity_id)) as amasty_related_ids')
->leftJoin('amasty_mostviewed_product_index as mainrule', function ($join) use ($builder) {
$join->on('mainrule.entity_id', '=', $builder->getQuery()->from.'.entity_id')
->where('mainrule.relation', 'where_show')
->whereIn('mainrule.position', ['product_into_related', 'product_into_upsell'])
->where('mainrule.store_id', config('rapidez.store'));
})
->leftJoin('amasty_mostviewed_group', 'mainrule.rule_id', '=', 'amasty_mostviewed_group.group_id')
->leftJoin('amasty_mostviewed_product_index as related', function ($join) {
$join->on('related.rule_id', '=', 'mainrule.rule_id')
->where('related.relation', 'what_show')
->whereIn('related.position', ['product_into_related', 'product_into_upsell'])
->where('related.store_id', config('rapidez.store'));
});
})
->leftJoin('cataloginventory_stock_item as related_stock', 'related_stock.product_id', '=', 'related.entity_id');
}
}

0 comments on commit 67b1e5e

Please sign in to comment.