Jump to content

Products in the same category - Not displaying correctly


Recommended Posts

Hi, I don't know why but from yesterday the module is not working properly.

I can see only the title and the price of the first product.

I run Prestashop 1.7.6.2 with Warehouse theme and in theme config I've only turned off the arrows and dots navigation and It has always worked properly (Even if I turn that back On nothing change).

I tryed to disinstall or reset the module but still same problems.

How can I fix it ?

Immagine.png

Link to comment
Share on other sites

  • 3 months later...

After further investigation, it seems the problem is with "themes/warehouse/templates/catalog/_partials/miniatures/_partials/product-miniature-thumb.tpl"

If you comment the last 3 blocks from the template "product_flags", "product_list_functional_buttons" and "product_availability" it will work.

But it will not show those blocks in categories list.

Link to comment
Share on other sites

  • 4 months later...
On 3/30/2020 at 12:01 AM, p00pstar said:

After further investigation, it seems the problem is with "themes/warehouse/templates/catalog/_partials/miniatures/_partials/product-miniature-thumb.tpl"

If you comment the last 3 blocks from the template "product_flags", "product_list_functional_buttons" and "product_availability" it will work.

But it will not show those blocks in categories list.

@p00pstar Thank you, that you found the problem. And I found solution. If you will remove in these 3 blocks all block code (I mean   {block name='product_flags'}  {/block} etc) then it will solve the problem. And all inside html will be there, so you will be able to see everywhere all flags and so on.

 

  • Like 2
Link to comment
Share on other sites

  • 11 months later...
  • 1 month later...
On 29/8/2020 at 5:06 PM, asdasd1234 dice:

@p00pstar Thank you, that you found the problem. And I found solution. If you will remove in these 3 blocks all block code (I mean   {block name='product_flags'}  {/block} etc) then it will solve the problem. And all inside html will be there, so you will be able to see everywhere all flags and so on.

 

I have the same problem but doesn't work, can you help me?

 

Link to comment
Share on other sites

  • 4 months later...

Its wrong cache key in ps_categoryproducts. This issue is there even for ps_viewedproducts module, especially for people using Warehouse theme, but its not related to the theme, but to the smarty cache (it works if its turned off). Simple solution is to disable smarty cache funccionality for those modules.

Products in the same category:

modules/ps_categoryproducts/ps_categoryproducts.php and find renderWidget function and replace it with following (cache is commented out)

public function renderWidget($hookName = null, array $configuration = array())
    {
        $params = $this->getInformationFromConfiguration($configuration);
        if ($params) {
            if ((int)Configuration::get('CATEGORYPRODUCTS_DISPLAY_PRODUCTS') > 0) {
                // Need variables only if this template isn't cached
                //if (!$this->isCached($this->templateFile, $params['cache_id'])) {
                    if (!empty($params['id_category'])) {
                        $category = new Category($params['id_category']);
                    }
                    if (empty($category) || !Validate::isLoadedObject($category) || !$category->active) {
                        return false;
                    }
                    $variables = $this->getWidgetVariables($hookName, $configuration);
                    if (empty($variables)) {
                        return false;
                    }
                    $this->smarty->assign($variables);
              //  }
                return $this->fetch(
                    $this->templateFile
                );
            }
        }
        return false;
    }

Viewed products:

modules/ps_viewedproducts/ps_viewedproducts.php and find renderWidget function and replace it with following (cache is commented out)

public function renderWidget($hookName = null, array $configuration = array())
    {
        if (isset($configuration['product']['id_product'])) {
            $this->currentProductId = $configuration['product']['id_product'];
        }
        if ('displayProductButtons' === $hookName || 'displayProductAdditionalInfo' === $hookName) {
            $this->addViewedProduct($this->currentProductId);
            return;
        }
        if (!isset($this->context->cookie->viewed) || empty($this->context->cookie->viewed)) {
            return;
        }
       // if (!$this->isCached($this->templateFile, $this->getCacheId())) {
            $variables = $this->getWidgetVariables($hookName, $configuration);
            if (empty($variables)) {
                return false;
            }
            $this->smarty->assign($variables);
       // }
       // return $this->fetch($this->templateFile, $this->getCacheId());
        return $this->fetch($this->templateFile);
    }

I have this fix on my 1.7.8.1 with PHP 7.4 and it works like a charm :)

  • Like 3
Link to comment
Share on other sites

  • 1 year later...
On 2/15/2022 at 8:42 PM, Holohugo said:

Its wrong cache key in ps_categoryproducts. This issue is there even for ps_viewedproducts module, especially for people using Warehouse theme, but its not related to the theme, but to the smarty cache (it works if its turned off). Simple solution is to disable smarty cache funccionality for those modules.

Products in the same category:

modules/ps_categoryproducts/ps_categoryproducts.php and find renderWidget function and replace it with following (cache is commented out)

public function renderWidget($hookName = null, array $configuration = array())
    {
        $params = $this->getInformationFromConfiguration($configuration);
        if ($params) {
            if ((int)Configuration::get('CATEGORYPRODUCTS_DISPLAY_PRODUCTS') > 0) {
                // Need variables only if this template isn't cached
                //if (!$this->isCached($this->templateFile, $params['cache_id'])) {
                    if (!empty($params['id_category'])) {
                        $category = new Category($params['id_category']);
                    }
                    if (empty($category) || !Validate::isLoadedObject($category) || !$category->active) {
                        return false;
                    }
                    $variables = $this->getWidgetVariables($hookName, $configuration);
                    if (empty($variables)) {
                        return false;
                    }
                    $this->smarty->assign($variables);
              //  }
                return $this->fetch(
                    $this->templateFile
                );
            }
        }
        return false;
    }

Viewed products:

modules/ps_viewedproducts/ps_viewedproducts.php and find renderWidget function and replace it with following (cache is commented out)

public function renderWidget($hookName = null, array $configuration = array())
    {
        if (isset($configuration['product']['id_product'])) {
            $this->currentProductId = $configuration['product']['id_product'];
        }
        if ('displayProductButtons' === $hookName || 'displayProductAdditionalInfo' === $hookName) {
            $this->addViewedProduct($this->currentProductId);
            return;
        }
        if (!isset($this->context->cookie->viewed) || empty($this->context->cookie->viewed)) {
            return;
        }
       // if (!$this->isCached($this->templateFile, $this->getCacheId())) {
            $variables = $this->getWidgetVariables($hookName, $configuration);
            if (empty($variables)) {
                return false;
            }
            $this->smarty->assign($variables);
       // }
       // return $this->fetch($this->templateFile, $this->getCacheId());
        return $this->fetch($this->templateFile);
    }

I have this fix on my 1.7.8.1 with PHP 7.4 and it works like a charm :)

removing cache from the modules is a fast solution but not the better one, The problem is on the theme because with other themes and classic theme the problem is not there.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...