Skip to content

Critical Error on getSwatchAttributseData() preventing listing of products in category #2879

Closed
@tigerx7

Description

@tigerx7

I'm not sure exactly if the root of the problem is with an issue on a swatch attribute or that the category only has one product, but nonetheless, it causes $result to never be assigned in the following class:

\Magento\Swatches\Block\Product\Renderer\Listing on function getSwatchAttributesData():

    protected function getSwatchAttributesData()
    {
        $swatchAttributeData = parent::getSwatchAttributesData();
        foreach ($swatchAttributeData as $attributeId => $item) {
            if (!empty($item['used_in_product_listing'])) {
                $result[$attributeId] = $item;
            }
        }
        return $result;
    }

The end result is that in production, the category is displayed, but there's no products listed.

I ended up overriding the class on my end and applied $result = []; prior to the foreach loop which seemed to have fixed it. I'm not sure if it'll cause issues anywhere else though.

Metadata

Metadata

Assignees

Labels

Issue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentbug report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions