PHP code example of infrangible / m2-catalog-product-swatches
1. Go to this page and download the library: Download infrangible/m2-catalog-product-swatches library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
infrangible / m2-catalog-product-swatches example snippets
/** @var \Infrangible\CatalogProductSwatches\Model\SwatchAttributes $swatchAttributes */
$swatchAttributes = $observer->getEvent()->getData('swatch_attributes');
$swatchAttributes->addAttribute(
$observer->getEvent()->getData('product'),
'pos', // attribute code
'.catalog-product-pos', // CSS selector of the element that shows the value
'catalog-product-pos-template', // ID of the element with the template (mage/template)
', ' // separator of the labels of multiselect attributes
);