From: Vincent Vanwaelscappel Date: Thu, 2 Apr 2020 15:40:03 +0000 (+0200) Subject: wip #3520 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=8fbf3fbfb310779698f9cd87a541e2d7f7339984;p=pmi.git wip #3520 @1 --- diff --git a/app/Templates/Category.php b/app/Templates/Category.php index 0890481..b1177f8 100644 --- a/app/Templates/Category.php +++ b/app/Templates/Category.php @@ -5,6 +5,7 @@ namespace App\Templates; use App\Models\Product; use App\Models\ProductType; +use Cubist\Backpack\app\Magic\Menu\PageItem; class Category extends Base { @@ -41,7 +42,7 @@ class Category extends Base public function setData(&$data) { parent::setData($data); - $cat=$data['page']->get('category'); + $cat = $data['page']->get('category'); $productType = ProductType::find($cat); @@ -68,4 +69,36 @@ class Category extends Base $data['filters'] = $filters ? $filters['filters'] : []; // To be used by Vue component $data['filter_results'] = $filters ? $filters['results'] : []; } + + public function setMenuChildren($menu) + { + $products = Product::whereVariant($menu->getVariant())->get(); + $data = $menu->getPageData(); + $cat = $data->get('category'); + $filter = $menu->getPageData()->get('filter', ''); + foreach ($products as $product) { + if ($product->product_type != $cat) { + continue; + } + if (!$product->online) { + continue; + } + + $canonical = $href = $product->getSlugOrTitleAttribute(); + if ($filter !== '') { + $href = $cat . '-' . $href; + } + + $detail = new PageItem(); + $detail->setLocale($menu->getLocale()); + $detail->initFromEntity($product); + $detail->setTitle($product->name); + $detail->setCanonical($canonical); + $detail->setHref($href); + $detail->setId('product/' . $product->id); + $detail->setController(['controller' => 'ProductController', 'action' => 'productDetails', 'params' => ['id' => $product->id]]); + $detail->hideInAllMenus(); + $menu->addChild($detail); + } + } } diff --git a/resources/js/components/ProductsFilters.vue b/resources/js/components/ProductsFilters.vue index 8811bc4..caba3bf 100644 --- a/resources/js/components/ProductsFilters.vue +++ b/resources/js/components/ProductsFilters.vue @@ -226,7 +226,6 @@ }, computed: { - resultsCount() { let count = Object.keys(this.matches.hits).length; let results = ''; @@ -246,7 +245,6 @@ }, filterQuerystring() { - let filter_list = []; Object.keys(this.filters).forEach(filterID => { diff --git a/resources/styles/components/products.styl b/resources/styles/components/products.styl index 3195b57..28f8504 100644 --- a/resources/styles/components/products.styl +++ b/resources/styles/components/products.styl @@ -48,9 +48,13 @@ grid-gap 20px grid-template-columns: repeat(auto-fill, minmax(100%, 1fr)) + .product-grid-item height 100px + .no-cssgrid & + width: 100%; + > a display inline-block vertical-align: top; diff --git a/resources/views/partials/product-link.blade.php b/resources/views/partials/product-link.blade.php index 032663e..c2a3178 100644 --- a/resources/views/partials/product-link.blade.php +++ b/resources/views/partials/product-link.blade.php @@ -3,7 +3,7 @@ @endphp
{{-- Image holder --}} - +