fix basket

This commit is contained in:
ludo
2023-10-31 17:05:41 +01:00
parent a9432bd3c1
commit 746cf661ce
14 changed files with 144 additions and 88 deletions

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Repositories\Shop;
use App\Models\Shop\Category;
use App\Repositories\Core\Categories as CategoryTrees;
use App\Repositories\Core\Tag;
class Shelves
{
public static function getOffersByCategoryAndNature($categoryId, $articleNatureId = false, $tags = [], $articleNature = false, $displayByRows = false)
{
$productTypes = Articles::getProductTypesWithOffers([
'category_id' => $categoryId,
]);
$articleNatures = Articles::getArticleNaturesWithOffers([
'category_id' => $categoryId,
]);
if ($articleNatureId) {
$productType = ArticleNatures::getProductType($articleNatureId);
} else {
if (! $articleNature) {
if (count($articleNatures)) {
$articleNature = $articleNatures[0];
}
}
$productType = ArticleNatures::getProductTypeBySlug($articleNature);
$articleNatureId = ArticleNatures::getIdBySlug($articleNature);
}
return [
'category' => Categories::getFull($categoryId),
'breadcrumb' => Categories::getAncestorsByCategory($categoryId),
'display_by_rows' => $displayByRows,
'product_type' => $productType,
'article_nature' => $articleNature,
'article_natures' => $articleNatures ?? [],
'product_types' => $productTypes ?? [],
'tags_selected' => $tags,
'articles' => Articles::getArticlesToSell([
'category_id' => $categoryId,
'tags' => $tags,
'product_type' => $productType ?? false,
'article_nature_id' => $articleNatureId ?? false,
]),
'tags' => TagGroups::getWithTagsAndCountOffers($categoryId),
];
}
}