I am looking for a solution for the following:
Example
2 Configurable products (sizes) of the Same T-shirt though different color:
- Configurable product T-shirt A color Blue (size 1-10)
- Configurable product T-shirt A color Red (size 1-10)
What is the best way to relate those products to eachother? I want for every color a different Page / URL.
How I would like to see is like this:
https://www.venroy.com.au/knitted-hoodie-grey-marl
You see different colours. And those colours are linked to different productpages / urls (so different configurable products).
How can i achieve this the best way?
Best Answer
For configurable child product visibility should be 'Catalog, Search'. So when you browse child product you need some custom code. So create a plugin for Magento\Catalog\Controller\Product\View::execute Following way:
VendorName/ModuleName/Plugin/Catalog/Controller/Product/View.php
Now you need to select/pre-select JS code. In that case, If you work with magento default 'select' option code then you need to overwrite 'Magento_ConfigurableProduct/js/configurable.js'. Or your case you need to overwrite 'Magento_Swatches/js/SwatchRenderer.js' _OnClick method and add your logic here.