Skip to content

specialPriceMap expects website ID, store ID given #40208

@HyperC

Description

@HyperC

Preconditions and environment

Magento version: 2.4.8-p1

\Magento\Catalog\Pricing\Price\SpecialPriceBulkResolver::generateSpecialPriceMap has $storeId as input, but the table catalog_product_index_price is filtered on website_id in that method.

Steps to reproduce

  1. Set a special price on a product on a Website and Storeview other than the default. Storeview ID must be higher than 3 and max 2 websites, to be sure it fails.
  2. Navigate to a catalog page. Observe the old price not being shown.

Expected result

Old and new price should be shown.

Actual result

Only new price is shown.

Additional information

Method generateSpecialPriceMap takes in storeId as an argument, but the method filters on website_id:

...
->joinLeft(
                ['price' => $this->resource->getTableName('catalog_product_index_price')],
                'price.entity_id = COALESCE(link.product_id, e.entity_id) AND price.website_id = ' . $storeId .
                ' AND price.customer_group_id = ' . $this->customerSession->getCustomerGroupId()
            )

Changing \Magento\Catalog\Block\Product\ListProduct::getPriceRender so it uses the website id fixes the problem:

protected function getPriceRender()
    {
        $block = $this->getLayout()->getBlock('product.price.render.default');
        $block->setData('is_product_list', true);

        if ($this->specialPriceMap === null) {
            $this->specialPriceMap = $this->specialPriceBulkResolver->generateSpecialPriceMap(
//                (int)$this->_storeManager->getStore()->getId(),
                (int)$this->_storeManager->getWebsite()->getId(),
                $this->_getProductCollection()
            );
        }

        return $block->setData('special_price_map', $this->specialPriceMap);
    }

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions