Powerful and easy to use cms to build websites, blogs or ecommerce stores.
HTML backendblogblog-engineblog-platformbloggingcmscontent-managementcontent-management-systemecommerceecommerce-platformno-codepage-builderphpphp-cmsphp7php8self-hostedshopping-cartweb-applicationwebsite-builder
Show 404 page if no products when component has 404 flag set
givanzbbefd33e3df5
diff --git a/app/component/products.php b/app/component/products.phpindex 03495aa..ab9c1f1 100755--- a/app/component/products.php+++ b/app/component/products.php@@ -61,9 +61,10 @@ class Products extends ComponentBase {'author' => null, //[true, false] include author/admin info'image_size' => 'medium','filter' => null, //[true, false] include variants- 'order_by' => NULL,'variant_price' => NULL,+ 'order_by' => NULL,'direction' => ['desc', 'asc'], //'url','asc', 'desc'+ '404' => NULL,];private $tax;@@ -141,7 +142,7 @@ class Products extends ComponentBase {$this->options['search'] .= '*';}- $results = $products->getAll($this->options) + $this->options;+ $results = $products->getAll($this->options);if ($results && isset($results['product'])) {$this->products($results['product'], $this->options);@@ -153,6 +154,14 @@ class Products extends ComponentBase {$results['start'] = $this->options['start'];$results['search'] = $this->options['search'] ?? '';+ if (! $results['product'] &&+ isset($this->options['page']) &&+ ($this->options['page'] > 1) &&+ (isset($this->options['404']) && $this->options['404']) &&+ ! $_SERVER['QUERY_STRING']) {+ $results['404'] = true;+ }+list($results) = Event :: trigger(__CLASS__,__FUNCTION__, $results);return $results;