Jump to content

Products in the same category only shows first product text


Recommended Posts

Hi everyone.

The module Products in the same category  is not displaying correctly on my website.

Only shows the first product and after that only the image.

I did a quick search and someone already has a issue and reported as a bug but i tried to make the necessary file changes to correct the issue but with no success.

Link to bug report: https://github.com/PrestaShop/ps_categoryproducts/issues/5

If i disable the cache it works just fine, but i need cache enabled.

Any tip are appreciated.

Thanks in advance.

Alex 

screenshot.jpg

Link to comment
Share on other sites

  • 6 months later...

Quick and dirty fix could be to disable caching for this specific module. Don't think you can do that from BO, you'd have to do some code changes. I remember doing it somewhere, I'll try to remember the exact steps and update this post.

EDIT: So I found I was modifying a different module and it was on PS 1.6, but I checked the ps_categoryproducts module and it might be similar.

Seems to me that the caching is checked in the function renderWidget in ps_categoryproducts.php

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,
                    $params['cache_id']
                );
            }
        }

        return false;
    }

If you change this part

return $this->fetch(
  $this->templateFile,
  $params['cache_id']
);

To this (if I understand it correctly, this should return invalid cache_id and thus force it load the template as if cache was disabled)

return $this->fetch(
  $this->templateFile,
  'cache_id'
);

It might work. But I wouldn't bet my life on it, I have no way of testing this. Maybe someone with more experience can help out with this.

Edited by direwald (see edit history)
Link to comment
Share on other sites

hace 2 minutos, direwald dijo:

Quick and dirty fix could be to disable caching for this specific module. Don't think you can do that from BO, you'd have to do some code changes. I remember doing it somewhere, I'll try to remember the exact steps and update this post.

Yeah! It sounds a bit dirty but it could work.
It would be great if you can remember those steps and post them. 

Thanks mate! 😜

Link to comment
Share on other sites

hace 7 minutos, direwald dijo:

Updated my previous post but I'm not sure if it's gonna work. Might be a start for someone more knowledgable though.

I have tried but it doesn't work for me.

Anyway thank you very much for your input. 

Let's see if someone can help us
 

Link to comment
Share on other sites

I'd imagine you could also change this if condition

// Need variables only if this template isn't cached
if (!$this->isCached($this->templateFile, $params['cache_id'])) {
.
.
.
.
.

to be always true (or just remove the if altogether) so the following code always happens, as that seems to handle caching as well.

Link to comment
Share on other sites

  • 9 months later...

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...