Fixes on articles by sale_channel
This commit is contained in:
@@ -120,10 +120,10 @@ class Article extends Model implements HasMedia
|
|||||||
return $query->has('offers');
|
return $query->has('offers');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopeWithAvailableOffers($query)
|
public function scopeWithAvailableOffers($query, $sale_channel_id = false)
|
||||||
{
|
{
|
||||||
return $query->whereHas('offers', function ($query) {
|
return $query->whereHas('offers', function ($query) use ($sale_channel_id) {
|
||||||
$query->active();
|
$query->active()->bySaleChannel($sale_channel_id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class Articles
|
|||||||
return Article::orderBy('name', 'asc')->get();
|
return Article::orderBy('name', 'asc')->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getArticleToSell($id)
|
public static function getArticleToSell($id, $sale_channel = false)
|
||||||
{
|
{
|
||||||
$article = self::get($id);
|
$article = self::get($id);
|
||||||
$data = $article->toArray();
|
$data = $article->toArray();
|
||||||
@@ -85,7 +85,7 @@ class Articles
|
|||||||
$data['inherited'] = self::getInherited($id);
|
$data['inherited'] = self::getInherited($id);
|
||||||
$data['categories'] = self::getCategoriesNameByArticle($article);
|
$data['categories'] = self::getCategoriesNameByArticle($article);
|
||||||
$data['tags'] = self::getTagsSlugByArticle($article);
|
$data['tags'] = self::getTagsSlugByArticle($article);
|
||||||
$data['offers'] = self::getOffersGroupedByNature($id);
|
$data['offers'] = self::getOffersGroupedByNature($id, $sale_channel);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,9 +135,10 @@ class Articles
|
|||||||
return $data ?? false;
|
return $data ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getArticlesWithOffers($category_id = false, $tags = false)
|
public static function getArticlesWithOffers($category_id = false, $tags = false, $sale_channel_id = false)
|
||||||
{
|
{
|
||||||
return Article::byCategory($category_id)->byTags($tags)->visible()->withAvailableOffers()->with([
|
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
||||||
|
return Article::byCategory($category_id)->byTags($tags)->visible()->withAvailableOffers($sale_channel_id)->with([
|
||||||
'image',
|
'image',
|
||||||
'product',
|
'product',
|
||||||
'article_nature',
|
'article_nature',
|
||||||
|
|||||||
Reference in New Issue
Block a user