Created
August 16, 2018 08:21
-
-
Save zeloc/59ba1f938f466d8df88d9bf1574e0611 to your computer and use it in GitHub Desktop.
Get the bundle options that have selections
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 | |
require_once('abstract.php'); | |
class Space48_Shell_Bundle_Options extends Mage_Shell_Abstract | |
{ | |
/** | |
* Entry point | |
*/ | |
public function run() | |
{ | |
$products = Mage::getModel('catalog/product')->getCollection(); | |
foreach($products as $product){ | |
$this->getBundleOptionsWithSelections($product); | |
} | |
} | |
public function getBundleOptionsWithSelections(Mage_Catalog_Model_Product $product) | |
{ | |
if($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE){ | |
$typeInstance = $product->getTypeInstance(true); | |
$typeInstance->setStoreFilter($product->getStoreId(), $product); | |
$optionCollection = $typeInstance->getOptionsCollection($product); | |
$selectionCollection = $typeInstance->getSelectionsCollection( | |
$typeInstance->getOptionsIds($product), | |
$product | |
); | |
/** @var $optionCollection Mage_Bundle_Model_Resource_Option_Collection */ | |
$options = $optionCollection->appendSelections($selectionCollection, false, | |
true | |
); | |
foreach($options as $option){ | |
$optionSelection = $option->getData('selections'); | |
if(is_array($optionSelection) && count($optionSelection) > 1){ | |
Mage::log('id: ' . $product->getId() . ' sku: ' . $product->getSku(), 6, 'debug.log', true); | |
break; | |
} | |
} | |
return $options; | |
} | |
} | |
} | |
$ids = new Space48_Shell_Bundle_Options(); | |
$ids->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment