Skip to main content
added 97 characters in body
Source Link
MR.R DNATH
  • 462
  • 2
  • 10

Why it is not working!!! Please see below

your function is inherited from below function which is protected. Yes, we can inherit protected function into our custom module but here slite difference is that we can not inherit private property.

protected function _prepareCollection()
    {
        $allowProductTypes = array();
        $allowProductTypeNodes = Mage::getConfig()
            ->getNode('global/catalog/product/type/grouped/allow_product_types')->children();
        foreach ($allowProductTypeNodes as $type) {
            $allowProductTypes[] = $type->getName();
        }

        $collection = Mage::getModel('catalog/product_link')->useGroupedLinks()
            ->getProductCollection()
            ->setProduct($this->_getProduct())
            ->addAttributeToSelect('*')
            ->addFilterByRequiredOptions()
            ->addAttributeToFilter('type_id', $allowProductTypes);

        if ($this->getIsReadonly() === true) {
            $collection->addFieldToFilter('entity_id', array('in' => $this->_getSelectedProducts()));
        }
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }

->setProduct($this->_getProduct()) this is the function which is private So we can not set current product object.That's why your code is not working. Just make it app/code/local/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Group.php

Why it is not working!!! Please see below

your function is inherited from below function which is protected. Yes, we can inherit protected function into our custom module but here slite difference is that we can not inherit private property.

protected function _prepareCollection()
    {
        $allowProductTypes = array();
        $allowProductTypeNodes = Mage::getConfig()
            ->getNode('global/catalog/product/type/grouped/allow_product_types')->children();
        foreach ($allowProductTypeNodes as $type) {
            $allowProductTypes[] = $type->getName();
        }

        $collection = Mage::getModel('catalog/product_link')->useGroupedLinks()
            ->getProductCollection()
            ->setProduct($this->_getProduct())
            ->addAttributeToSelect('*')
            ->addFilterByRequiredOptions()
            ->addAttributeToFilter('type_id', $allowProductTypes);

        if ($this->getIsReadonly() === true) {
            $collection->addFieldToFilter('entity_id', array('in' => $this->_getSelectedProducts()));
        }
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }

->setProduct($this->_getProduct()) this is the function which is private So we can not set current product object.That's why your code is not working.

Why it is not working!!! Please see below

your function is inherited from below function which is protected. Yes, we can inherit protected function into our custom module but here slite difference is that we can not inherit private property.

protected function _prepareCollection()
    {
        $allowProductTypes = array();
        $allowProductTypeNodes = Mage::getConfig()
            ->getNode('global/catalog/product/type/grouped/allow_product_types')->children();
        foreach ($allowProductTypeNodes as $type) {
            $allowProductTypes[] = $type->getName();
        }

        $collection = Mage::getModel('catalog/product_link')->useGroupedLinks()
            ->getProductCollection()
            ->setProduct($this->_getProduct())
            ->addAttributeToSelect('*')
            ->addFilterByRequiredOptions()
            ->addAttributeToFilter('type_id', $allowProductTypes);

        if ($this->getIsReadonly() === true) {
            $collection->addFieldToFilter('entity_id', array('in' => $this->_getSelectedProducts()));
        }
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }

->setProduct($this->_getProduct()) this is the function which is private So we can not set current product object.That's why your code is not working. Just make it app/code/local/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Group.php

Source Link
MR.R DNATH
  • 462
  • 2
  • 10

Why it is not working!!! Please see below

your function is inherited from below function which is protected. Yes, we can inherit protected function into our custom module but here slite difference is that we can not inherit private property.

protected function _prepareCollection()
    {
        $allowProductTypes = array();
        $allowProductTypeNodes = Mage::getConfig()
            ->getNode('global/catalog/product/type/grouped/allow_product_types')->children();
        foreach ($allowProductTypeNodes as $type) {
            $allowProductTypes[] = $type->getName();
        }

        $collection = Mage::getModel('catalog/product_link')->useGroupedLinks()
            ->getProductCollection()
            ->setProduct($this->_getProduct())
            ->addAttributeToSelect('*')
            ->addFilterByRequiredOptions()
            ->addAttributeToFilter('type_id', $allowProductTypes);

        if ($this->getIsReadonly() === true) {
            $collection->addFieldToFilter('entity_id', array('in' => $this->_getSelectedProducts()));
        }
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }

->setProduct($this->_getProduct()) this is the function which is private So we can not set current product object.That's why your code is not working.