Skip to content

Instantly share code, notes, and snippets.

@WENKz
Created August 9, 2016 14:27
Show Gist options
  • Save WENKz/bac8935dc19c9e7e311c01e6e0491372 to your computer and use it in GitHub Desktop.
Save WENKz/bac8935dc19c9e7e311c01e6e0491372 to your computer and use it in GitHub Desktop.
get super attribute otpion value from configurable Magento
<?php
ini_set('memory_limit', '2048M');
error_reporting(E_ALL | E_STRICT);
define('MAGENTO_ROOT', getcwd());
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_erors', 1);
Mage::app()->setCurrentStore(3);
$products=Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect("sku")->addAttributeToSelect("id");
/*$configurableAttributeCollection=$product->getTypeInstance()->getConfigurableAttributes();
foreach($configurableAttributeCollection as $attribute){
$attributeid = $attribute->getProductAttribute()->getId();
//echo "super:->".$attributeid."";
$new = $attributeid;
} */
$products=Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect("sku")->addAttributeToSelect("*")->addAttributeToFilter('type_id', 'configurable');
foreach($products as $prod){
$product = Mage::getModel('catalog/product')->load($prod->getEntityId());
$productAttributeOptions = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
// var_dump($productAttributeOptions);
$attributeOptions = array();
foreach ($productAttributeOptions as $productAttribute) {
echo $productAttribute['label']."";
echo $productAttribute['attribute_id']."-------"."<br>";
foreach ($productAttribute['values'] as $attribute) {
echo "sku".$product->getSku().";id:".$attribute['value_index'].";price:".$attribute['pricing_value']. $attribute['store_label']."";
echo "<br>";
}
echo "<br>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment