0

I want to sort magento bundle product selected sort order on magento admin.i have changed below code file but nothing happen.i don't know from where it collect collection of product so i can set order. I have set order on this function but nothing changed.

Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option

    public function getOptions()
{
    if (!$this->_options) {
        $this->getProduct()->getTypeInstance(true)->setStoreFilter($this->getProduct()->getStoreId(),
            $this->getProduct());

        $optionCollection = $this->getProduct()->getTypeInstance(true)->getOptionsCollection($this->getProduct());

        $selectionCollection = $this->getProduct()->getTypeInstance(true)->getSelectionsCollection(
            $this->getProduct()->getTypeInstance(true)->getOptionsIds($this->getProduct()),
            $this->getProduct()
        );

        $this->_options = $optionCollection->appendSelections($selectionCollection);
        if ($this->getCanReadPrice() === false) {
            foreach ($this->_options as $option) {
                if ($option->getSelections()) {
                    foreach ($option->getSelections() as $selection) {
                        $selection->setCanReadPrice($this->getCanReadPrice());
                        $selection->setCanEditPrice($this->getCanEditPrice());
                    }
                }
            }
        }
    }

    return $this->_options;
}

enter image description here

0

The class to modify/extend is Mage_Bundle_Model_Product_Type then function getSelectionsCollection.

    public function getSelectionsCollection($optionIds, $product = null)
{
    $keyOptionIds = (is_array($optionIds) ? implode('_', $optionIds) : '');
    $key = $this->_keySelectionsCollection . $keyOptionIds;
    if (!$this->getProduct($product)->hasData($key)) {
        $storeId = $this->getProduct($product)->getStoreId();
        $selectionsCollection = Mage::getResourceModel('bundle/selection_collection')
                ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
                ->addAttributeToSelect('tax_class_id') //used for calculation item taxes in Bundle with Dynamic Price
                ->setFlag('require_stock_items', true)
                ->setFlag('product_children', true)
                //->setPositionOrder() //comment this line
                ->setOrder('name', 'asc') //add this line
                ->addStoreFilter($this->getStoreFilter($product))
                ->setStoreId($storeId)
                ->addFilterByRequiredOptions()
                ->setOptionIdsFilter($optionIds);

        if (!Mage::helper('catalog')->isPriceGlobal() && $storeId) {
            $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
            $selectionsCollection->joinPrices($websiteId);
        }

        $this->getProduct($product)->setData($key, $selectionsCollection);
    }
    return $this->getProduct($product)->getData($key);
}

Thanks to subroutines

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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