Magento 2 : How to get product size Swatches in Configurable product page?
-
15-04-2021 - |
문제
I have a custom module in my product page which allows customers to ask them notify them when an out of stock product size comes back in stock. I want to get out of stock product size swatches on a custom form inside a modal in product page but Im not able to get the swatches when I add block in layout.
<block class="Magento\Framework\View\Element\Template" name="custom-modal" template="Vendor_module::custom-modal.phtml" >
<block class="Magento\Swatches\Block\Product\Renderer\Configurable" name="product.info.options.swatches_inside_modal" />
</block>
How can I get out of stock product size swatches inside my custom-modal.phtml?
해결책
Found the Answer
Add appropriate block in your Product page
<block class="Magento\Swatches\Block\Product\Renderer\Listing\Configurable" name="product.info.options.swatches_inside_modal" template="Magento_Swatches::product/view/renderer.phtml" />
Then call the html in the Phtml
<?= $this->getChildHtml('product.info.options.swatches_inside_modal') ?>
제휴하지 않습니다 magento.stackexchange