How to display Swatches into the product list page into custom modules with add to cart functionality.
We need to display properly selected options with the configuration product into cart.
magento2swatches
How to display Swatches into the product list page into custom modules with add to cart functionality.
We need to display properly selected options with the configuration product into cart.
Best Answer
Vendor/Module/registration.php put below code.
add the module.xml file in Vendor/Module/etc/module.xml put below code.
Create Layout file for module and put below code in XML file
Create Template file for module and put below code in phtml file for listing product with swatches and I am assuming that you have loaded $_item
Create renderer.phtml file in Vendor/Module/view/frontend/templates/product/listing with below code:
Create custom-swatch-renderer.js file in Vendor/Module/view/frontend/web/js with below code:
Create Controller for add to cart in Vendor/Module/Controller/Cart/Add.php