How to enable configurable swatches option on catalog search?

I don't know why, the configurable swatches color is not showing on catalog search, but its working fine on Product list pages.

Catalog Search Page : enter image description here

Product List Page : enter image description here

Configurable Swatches color not showing on catalog search product list.

in catalogsearch result.phtml, I'm including the product list template to the result.phtml. But configurable swatches option still not showing on catalogsearch product list.

<div class="search results">
    <?php if ($messages = $block->getNoteMessages()): ?>
        <div class="message notice">
                <?php foreach ($messages as $message): ?>
                    <?= /* @escapeNotVerified */
                    $message ?><br/>
                <?php endforeach; ?>
    <?php endif; ?>
    <?= $block->getProductListHtml() ?>


Create catalogsearch_result_index.xml file on this path


And add following code in catalogsearch_result_index.xml File.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <referenceBlock name="category.product.type.details.renderers">
        <block class="Magento\Swatches\Block\Product\Renderer\Listing\Configurable" as="configurable" template="Magento_Swatches::product/listing/renderer.phtml" />

Save file and flush cache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.