Add prices and filtering by sale_channel with default

This commit is contained in:
Ludovic CANDELLIER
2022-02-22 22:32:46 +01:00
parent 3c3481b39d
commit f8c686caa3
6 changed files with 43 additions and 13 deletions

View File

@@ -27,15 +27,14 @@ class Articles
return $export;
}
public static function getOffersGroupedByNature($id)
public static function getOffersGroupedByNature($id, $sale_channel_id = false)
{
$article_ids = self::getSiblingsIds($id);
$offers = Offers::getOffersByArticles($article_ids);
// dump($offers->toArray());
$offers = Offers::getOffersByArticles($article_ids, $sale_channel_id);
foreach ($offers as $offer) {
$data[$offer->article_nature->name][] = [
$data[strtolower($offer->article_nature->name)] = [
'name' => $offer->variation->name,
'tariff' => $offer->tariff,
'prices' => $offer->tariff->price_lists->first()->price_list_values->toArray(),
];
}
return $data;
@@ -86,7 +85,7 @@ class Articles
$data['inherited'] = self::getInherited($id);
$data['categories'] = self::getCategoriesNameByArticle($article);
$data['tags'] = self::getTagsSlugByArticle($article);
$data['offers'] = self::getOffersById($id)->toArray();
$data['offers'] = self::getOffersGroupedByNature($id);
return $data;
}