Amjath Jayakumar
Amjath Jayakumar

Reputation: 51

How to get attribute codes of super product attributes of a configurable product

For example, a configurable product with attributes Size and Color, I need to get the attribute codes of the above attributes.

or to be more specific, I need to know whether an attribute is used to configure a configurable product. I need this to check at product list page

Upvotes: 0

Views: 6218

Answers (2)

Wolfack
Wolfack

Reputation: 2769

Create an array as shown below:

$attributeValues['additional_options'][$count]['label'] = $aAttr['name'];
$attributeValues['additional_options'][$count]['value'] = $aAttr['value'];

Then pass the array while adding items to the order:

if (!empty($product['product_options'])) {
    $orderItem->setProductOptions($product['product_options']);
}

Here $product['product_options'] is the array that we have created in the first step.

Upvotes: 0

Deepak Mallah
Deepak Mallah

Reputation: 4076

try using this code

$config_product = Mage::getModel('catalog/product')->load($config_product_id);
$productAttributeOptions = $config_product->getTypeInstance(true)->getConfigurableAttributesAsArray($config_product);

Upvotes: 4

Related Questions