Fix on default sale channel

This commit is contained in:
Ludovic CANDELLIER
2022-03-07 22:58:40 +01:00
parent aa50f908ba
commit 0eaa11b2a9
2 changed files with 19 additions and 4 deletions

View File

@@ -75,8 +75,9 @@ class Articles
return Article::orderBy('name', 'asc')->get();
}
public static function getArticleToSell($id, $sale_channel = false)
public static function getArticleToSell($id, $sale_channel_id = false)
{
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
$article = self::get($id);
$data = $article->toArray();
$parents = self::getInheritedByProduct($article->product_id, $article->product_type);
@@ -87,7 +88,7 @@ class Articles
$data['inherited'] = self::getInherited($id);
$data['categories'] = self::getCategoriesNameByArticle($article);
$data['tags'] = self::getTagsSlugByArticle($article);
$data['offers'] = self::getOffersGroupedByNature($id, $sale_channel);
$data['offers'] = self::getOffersGroupedByNature($id, $sale_channel_id);
return $data;
}

View File

@@ -10,7 +10,14 @@ class Offers
{
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
return Offer::active()
->with(['article_nature', 'variation', 'tariff.price_lists.price_list_values'])
->with([
'article_nature',
'variation',
'tariff.price_lists' => function($query) use ($sale_channel_id) {
$query->bySaleChannel($sale_channel_id);
},
'tariff.price_lists.price_list_values',
])
->byArticles($articles_ids)
->bySaleChannel($sale_channel_id)
->get();
@@ -20,7 +27,14 @@ class Offers
{
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
return Offer::active()
->with(['article_nature', 'variation', 'tariff.price_lists.price_list_values'])
->with([
'article_nature',
'variation',
'tariff.price_lists' => function($query) use ($sale_channel_id) {
$query->bySaleChannel($sale_channel_id);
},
'tariff.price_lists.price_list_values',
])
->byArticle($article_id)
->bySaleChannel($sale_channel_id)
->get();