Jump to content
thirty bees forum
  • 0

Question

Posted

The blocknewproducts module (ver 2.1.3) does not show products on the categories page when I enable Smarty cache.
It seems to me that in hookRightColumn() the BlockNewProducts::$cache_new_products is not checked there.
I changed the function a bit, and then everything works:

    public function hookRightColumn()
    {
        if (!$this->isCached('blocknewproducts.tpl', $this->getCacheId())) {
            if (!isset(BlockNewProducts::$cache_new_products))
                BlockNewProducts::$cache_new_products = $this->getNewProducts();

            if (!BlockNewProducts::$cache_new_products) {
                return false;
            }

            $this->smarty->assign([
                'new_products' => BlockNewProducts::$cache_new_products,
                'mediumSize'   => Image::getSize(ImageType::getFormatedName('medium')),
                'homeSize'     => Image::getSize(ImageType::getFormatedName('home')),
            ]);
        }

        return $this->display(__FILE__, 'blocknewproducts.tpl', $this->getCacheId());
    }

 

Also in hookdisplayHomeTab(), the BlockNewProducts::$cache_new_products check should be used in the IF block, and in hookdisplayHomeTabContent(), the check is generally meaningless.

    public function hookdisplayHomeTab()
    {
        if (!$this->isCached('tab.tpl', $this->getCacheId('blocknewproducts-tab'))) {
            BlockNewProducts::$cache_new_products = $this->getNewProducts();
            
            if (!BlockNewProducts::$cache_new_products)
                return false;
        }

        return $this->display(__FILE__, 'tab.tpl', $this->getCacheId('blocknewproducts-tab'));
    }

    public function hookdisplayHomeTabContent()
    {
        if (!$this->isCached(
            'blocknewproducts_home.tpl',
            $this->getCacheId('blocknewproducts-home'))
        ) {
            $this->smarty->assign([
                'new_products' => BlockNewProducts::$cache_new_products,
                'mediumSize'   => Image::getSize(ImageType::getFormatedName('medium')),
                'homeSize'     => Image::getSize(ImageType::getFormatedName('home')),
            ]);
        }

        return $this->display(
            __FILE__,
            'blocknewproducts_home.tpl',
            $this->getCacheId('blocknewproducts-home')
        );
    }

Tell me, my corrections are correct?

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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