I can get current product attribute using $product->getAttributes(). How can I get the configurable product list and their corresponding attributes programmatically?


You can use \Magento\ConfigurableProduct\Api\LinkManagementInterface::getChildren to get list of child for configurable product and \Magento\ConfigurableProduct\Api\OptionRepositoryInterface::getList to get list of attributes that used to create configurable product


Navigate to vendor/magento/module-configurable-product/Model/Product/Type/Configurable.php, we can see getConfigurableAttributes($product) to retrieve the configurable attributes.


/**@var \Magento\ConfigurableProduct\Model\Product\Type\Configurable $_model**/
/**@var \Magento\Catalog\Model\Product $product **/

  • I have set the configurable in admin panel. But when I run $product->getConfigurableAttributes($product), it returns empty. – Paul Aug 9 '16 at 16:21
  • 1
    Magento recomend use Service Layer API. Any other code can be changed/removed – KAndy Aug 9 '16 at 16:22

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.