2

How to include configurable swatches on other listing like cross sell , bestseller or in a custom module product listing ?

1

You can do this with injecting of this block

Magento_Swatches::product/listing/renderer.phtml

Like this

    $swatchBlock = $this->getLayout()
     ->createBlock("Magento\Swatches\Block\Product\Renderer\Listing\Configurable")
     ->setTemplate("Magento_Swatches::product/listing/renderer.phtml");

    echo $swatchBlock->setProduct($_product)->toHtml();

And add the to your page

| improve this answer | |

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.