]> _ Git - pmi.git/commitdiff
wip #3520 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 2 Apr 2020 15:40:03 +0000 (17:40 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 2 Apr 2020 15:40:03 +0000 (17:40 +0200)
app/Templates/Category.php
resources/js/components/ProductsFilters.vue
resources/styles/components/products.styl
resources/views/partials/product-link.blade.php

index 0890481abd0fefc54597345a24705f73e634abea..b1177f8e3f3fe451c36a3feb212959ccca5c6482 100644 (file)
@@ -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);
+        }
+    }
 }
index 8811bc49a38bf643f18ce8c2f1199867c1621222..caba3bfea363a285d8fbb141ad27367003c5d601 100644 (file)
         },
 
         computed: {
-
             resultsCount() {
                 let count = Object.keys(this.matches.hits).length;
                 let results = '';
             },
 
             filterQuerystring() {
-
                 let filter_list = [];
 
                 Object.keys(this.filters).forEach(filterID => {
index 3195b57f26c729fce84e785b792f7b6139e51189..28f85041d5d6de07e8e13b7dd099bcc96a7f8d35 100644 (file)
           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;
index 032663e3dbcbafc36c489093baf1e992d354cc3a..c2a31785f1f1a060a7320cd240125aa4a4cefddf 100644 (file)
@@ -3,7 +3,7 @@
 @endphp
 <div data-product-id="{{$id}}" class="product-grid-item bg-grey-200">
     {{-- Image holder --}}
-    <a href="{{ $product->getEntity()->URL }}">
+    <a href="{{ $product->getEntity()->getURLAttribute() }}" class="">
         <div class="product-img-holder">
             <div class="product-img">
                 <img src="{{$product->getEntity()->image}}"
@@ -14,7 +14,7 @@
     There shoulln't be any space between closing of a and opening of div
     {{-- Product details --}}
     --><div class="product-content p-4">
-        <h3><a class="text-navy" href="{{ $product->getEntity()->URL }}">{{ $product->get('reference') }}</a>
+        <h3><a class="text-navy" href="{{ $product->getEntity()->getURLAttribute() }}">{{ $product->get('reference') }}</a>
         </h3>
         <div class="product-highlights text-sm">
             {{$product->get('name')}}
@@ -24,7 +24,7 @@
         @endif
         <div class="links mt-4">
             <div class="link">
-                <a href="{{ $product->getEntity()->URL }}">
+                <a href="{{ $product->getEntity()->getURLAttribute() }}">
                     {{ __('En savoir plus') }}
                 </a>
             </div>