magento2: Widget cache error

Steps to reproduce

  1. Install Magento from develop branch.
  2. Add two widgets of type ‘Catalog Product List’ to the ‘CMS homepage’ at location content.bottom with different titles, but the same conditions. For example, condition could be product price is greater than 0
  3. Refresh cache and visit homepage

Expected result

  1. Two widgets appear on homepage with the same products, but different titles.

Actual result

  1. First widget loaded shows twice depending on sort order
  2. See: Magento\CatalogWidget\Block\Product\ProductList::getCacheKeyInfo which doesn’t take into consideration the widget_id.
    /**
     * Get key pieces for caching block content
     *
     * @return array
     */
    public function getCacheKeyInfo()
    {
        $conditions = $this->getData('conditions')
            ? $this->getData('conditions')
            : $this->getData('conditions_encoded');

        return [
            'CATALOG_PRODUCTS_LIST_WIDGET',
            $this->_storeManager->getStore()->getId(),
            $this->_design->getDesignTheme()->getId(),
            $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_GROUP),
            intval($this->getRequest()->getParam(self::PAGE_VAR_NAME, 1)),
            $this->getProductsPerPage(),
            $conditions
        ];
    }

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 19 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @twslade. Thank you for your report. The issue has been fixed in magento/magento2#14816 by @ihor-sviziev in 2.3-develop branch Related commit(s):

The fix will be available with the upcoming 2.3.0 release.