Created
August 9, 2016 14:27
-
-
Save WENKz/bac8935dc19c9e7e311c01e6e0491372 to your computer and use it in GitHub Desktop.
get super attribute otpion value from configurable Magento
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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