]> _ Git - pmi.git/commitdiff
fix #2959 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 23 Aug 2019 10:16:05 +0000 (12:16 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 23 Aug 2019 10:16:05 +0000 (12:16 +0200)
app/Models/Product.php
app/Templates/Catalog.php

index a87c8ba63af117783821868d788b6d5b37fc4781..2204c894e3275822441f91e2acc810d48860f0ca 100644 (file)
@@ -14,6 +14,11 @@ class Product extends CubistMagicPageModel
     protected static $_productTypes = null;
     protected static $_specificationFields = null;
 
+    /**
+     * @var array
+     */
+    protected $_slugFields = ['slug', 'reference+name'];
+
     protected $table = 'catalog_products';
 
     protected $_options = ['name' => 'product',
@@ -279,7 +284,9 @@ class Product extends CubistMagicPageModel
             } else if ($specEntity->type == 'text') {
                 $specValue = trim($val);
             } else if ($specEntity->type == 'range') {
-
+                if (!$val['first'] && !$val['second']) {
+                    continue;
+                }
                 $specValue = $val['first'] . ' ' . __('à') . ' ' . $val['second'] . ' ' . $specEntity->unit;
             } else if ($specEntity->type == 'list') {
                 $option = Json::decodeRecursive($specEntity->options, Json::TYPE_ARRAY)[$val];
@@ -301,7 +308,8 @@ class Product extends CubistMagicPageModel
      * Custom accessor to return fallback image
      * by accessing $product->image_fallback...
      */
-    public function getImageFallbackAttribute() {
+    public function getImageFallbackAttribute()
+    {
         return asset('images/product-details/product-placeholder.svg');
     }
 
@@ -309,7 +317,8 @@ class Product extends CubistMagicPageModel
      * Custom accessor to return main product image (or fallback)
      * by accessing $product->image...
      */
-    public function getImageAttribute() {
+    public function getImageAttribute()
+    {
         if ($this->images) {
 
             $image = $this->getFirstMediaUrl($this->images);
@@ -327,7 +336,8 @@ class Product extends CubistMagicPageModel
      * Fetch selected product data for use in cart Vue component
      * @return array
      */
-    public static function getCartData() {
+    public static function getCartData()
+    {
 
         $cart_items = session('cart_items', []);
 
index c37ea76c81ff8bb93279abf611b1ce13ab595d74..52fd70d733f5eaac79f84be35641177d170b1177 100644 (file)
@@ -49,7 +49,7 @@ class Catalog extends TemplateAbstract
 
                 $category = new Item();
                 $category->setTitle($productType->name);
-                $category->setHref($productType->slug);
+                $category->setHref($productType->getSlugOrTitleAttribute());
                 $category->setId('product_type_' . $productType->id);
                 $category->setController(['controller' => 'ProductController', 'action' => 'productList', 'params' => ['id' => $productType->id]]);
 
@@ -63,7 +63,7 @@ class Catalog extends TemplateAbstract
                     }
                     $detail = new Item();
                     $detail->setTitle($product->name);
-                    $detail->setHref($product->slug);
+                    $detail->setHref($product->getSlugOrTitleAttribute());
                     $detail->setId('product/' . $product->id);
                     $detail->setController(['controller' => 'ProductController', 'action' => 'productDetails', 'params' => ['id' => $product->id]]);
                     $category->addChild($detail);