2

I have this script which gets all bundle products

$View = 2;

$products = Mage::getModel('catalog/product')
                ->setStoreId($View)
                ->getCollection()
                ->addAttributeToSelect('*')
                ->addAttributeToSelect('type')
                ->addFieldToFilter('type_id', array('eq' => 'bundle'))
                ;

Then I do this to cycle them and I try to get Store View Title (which is title)

foreach($products as $bundle)
{
        $productId = $bundle->getId();

        $bundled_product = new Mage_Catalog_Model_Product();      
        $bundled_product->load($productId);

        $typeInstance = $bundled_product->getTypeInstance(true);

        $selectionCollection = $typeInstance->getSelectionsCollection(
            $typeInstance->getOptionsIds($bundled_product), $bundled_product
        );

        $optionCollection = $typeInstance->getOptionsCollection($bundled_product);

        $_options = $optionCollection->appendSelections($selectionCollection, false, Mage::helper('catalog/product')->getSkipSaleableCheck());

        $bundle_option = array();

        foreach ($_options as $key => $value) 
        {
            echo $value->getData('title'); //Doesn't work, print nothing
            echo $value->getData('default_title'); //It Works
        }
}

However, despite I set the store_id to be what I want, it seems like it still takes the default view.

How can I print the Store View Title then?

1 Answer 1

0

Change below code

$bundled_product = new Mage_Catalog_Model_Product();      
$bundled_product->load($productId);

To

$bundled_product = new Mage_Catalog_Model_Product();      
$bundled_product->setStoreId($storeId)->load($productId);
3
  • Thanks but it is still not working. It still prints an empty string
    – Donny
    Apr 4, 2019 at 14:06
  • Please run indexing and flush cache and try again Apr 4, 2019 at 14:16
  • I ran it but it won't work
    – Donny
    Apr 4, 2019 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.