how to get progmatically swatches attribute option data in magento 2. I tried this:-

$options = $this->_attrOptionCollectionFactory->create()->setAttributeFilter(
                        'asc', true

with this above code i only get option data, not the swatches value. Please advice.

| improve this question | | | | |

You Can get all the swatches attribute option data with below code.


$attributes = $_product->getTypeInstance(true)->getConfigurableAttributesAsArray($_product); 

foreach ($attributes as $attribute){

    foreach($attribute['values'] as $data){
        echo "<pre>";

| improve this answer | | | | |
  • what exactly you are doing? Please specify it. – Gopal Patel Apr 7 '17 at 7:47
  • I need to attribute data with swatches data into attribute option. Not for particular product. – Karangar Meghnathi Apr 8 '17 at 7:40

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.