Override bloks and models in Magento 1.9.4.0 is not working












0















I'm trying to override the function _prepareCollection in Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid class



    <?php
class Ayasoftware_RequiredOptions_Block_Adminhtml_Catalog_Product_Edit_Tab_Super_Config_Grid extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid
{
protected function _prepareCollection()
{
echo "testing if overridden ";
$allowProductTypes = array();
foreach (Mage::helper('catalog/product_configuration')->getConfigurableAllowedTypes() as $type) {
$allowProductTypes = $type->getName();
}

$product = $this->_getProduct();
$collection = $product->getCollection()
->addAttributeToSelect('name')
->addAttributeToSelect('sku')
->addAttributeToSelect('attribute_set_id')
->addAttributeToSelect('type_id')
->addAttributeToSelect('price')
->addFieldToFilter('attribute_set_id',$product->getAttributeSetId())
->addFieldToFilter('type_id', $allowProductTypes)
// ->addFilterByRequiredOptions()
->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'inner');

if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
Mage::getModel('cataloginventory/stock_item')->addCatalogInventoryToProductCollection($collection);
}

foreach ($product->getTypeInstance(true)->getUsedProductAttributes($product) as $attribute) {
$collection->addAttributeToSelect($attribute->getAttributeCode());
$collection->addAttributeToFilter($attribute->getAttributeCode(), array('notnull'=>1));
}

$this->setCollection($collection);

if ($this->isReadonly()) {
$collection->addFieldToFilter('entity_id', array('in' => $this->_getSelectedProducts()));
}

parent::_prepareCollection();
return $this;
}
}


in my config.xml I have this



    <?xml version="1.0"?>
<config>
<modules>
<Ayasoftware_RequiredOptions>
<version>0.1.0</version>
</Ayasoftware_RequiredOptions>
</modules>
<global>
<helpers>
<requiredoptions>
<class>Ayasoftware_RequiredOptions_Helper</class>
</requiredoptions>
</helpers>
<blocks>
<requiredoptions>
<class>Ayasoftware_RequiredOptions_Block</class>
</requiredoptions>
<adminhtml>
<rewrite>
<catalog_product_edit_tab_super_config_grid>Ayasoftware_RequiredOptions_Block_Adminhtml_Catalog_Product_Edit_Tab_Super_Config_Grid</catalog_product_edit_tab_super_config_grid>
</rewrite>
</adminhtml>
</blocks>
<models>
<requiredoptions>
<class>Ayasoftware_RequiredOptions_Model</class>
<resourceModel>requiredoptions_mysql4</resourceModel>
</requiredoptions>

</models>
</global>
</config>


the function _prepareCollection is overridden correctly, but still using the original function that does not filter by ->addFilterByRequiredOptions()



any idea how to fix this?
was working fine in older versions.









share



























    0















    I'm trying to override the function _prepareCollection in Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid class



        <?php
    class Ayasoftware_RequiredOptions_Block_Adminhtml_Catalog_Product_Edit_Tab_Super_Config_Grid extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid
    {
    protected function _prepareCollection()
    {
    echo "testing if overridden ";
    $allowProductTypes = array();
    foreach (Mage::helper('catalog/product_configuration')->getConfigurableAllowedTypes() as $type) {
    $allowProductTypes = $type->getName();
    }

    $product = $this->_getProduct();
    $collection = $product->getCollection()
    ->addAttributeToSelect('name')
    ->addAttributeToSelect('sku')
    ->addAttributeToSelect('attribute_set_id')
    ->addAttributeToSelect('type_id')
    ->addAttributeToSelect('price')
    ->addFieldToFilter('attribute_set_id',$product->getAttributeSetId())
    ->addFieldToFilter('type_id', $allowProductTypes)
    // ->addFilterByRequiredOptions()
    ->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'inner');

    if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
    Mage::getModel('cataloginventory/stock_item')->addCatalogInventoryToProductCollection($collection);
    }

    foreach ($product->getTypeInstance(true)->getUsedProductAttributes($product) as $attribute) {
    $collection->addAttributeToSelect($attribute->getAttributeCode());
    $collection->addAttributeToFilter($attribute->getAttributeCode(), array('notnull'=>1));
    }

    $this->setCollection($collection);

    if ($this->isReadonly()) {
    $collection->addFieldToFilter('entity_id', array('in' => $this->_getSelectedProducts()));
    }

    parent::_prepareCollection();
    return $this;
    }
    }


    in my config.xml I have this



        <?xml version="1.0"?>
    <config>
    <modules>
    <Ayasoftware_RequiredOptions>
    <version>0.1.0</version>
    </Ayasoftware_RequiredOptions>
    </modules>
    <global>
    <helpers>
    <requiredoptions>
    <class>Ayasoftware_RequiredOptions_Helper</class>
    </requiredoptions>
    </helpers>
    <blocks>
    <requiredoptions>
    <class>Ayasoftware_RequiredOptions_Block</class>
    </requiredoptions>
    <adminhtml>
    <rewrite>
    <catalog_product_edit_tab_super_config_grid>Ayasoftware_RequiredOptions_Block_Adminhtml_Catalog_Product_Edit_Tab_Super_Config_Grid</catalog_product_edit_tab_super_config_grid>
    </rewrite>
    </adminhtml>
    </blocks>
    <models>
    <requiredoptions>
    <class>Ayasoftware_RequiredOptions_Model</class>
    <resourceModel>requiredoptions_mysql4</resourceModel>
    </requiredoptions>

    </models>
    </global>
    </config>


    the function _prepareCollection is overridden correctly, but still using the original function that does not filter by ->addFilterByRequiredOptions()



    any idea how to fix this?
    was working fine in older versions.









    share

























      0












      0








      0








      I'm trying to override the function _prepareCollection in Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid class



          <?php
      class Ayasoftware_RequiredOptions_Block_Adminhtml_Catalog_Product_Edit_Tab_Super_Config_Grid extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid
      {
      protected function _prepareCollection()
      {
      echo "testing if overridden ";
      $allowProductTypes = array();
      foreach (Mage::helper('catalog/product_configuration')->getConfigurableAllowedTypes() as $type) {
      $allowProductTypes = $type->getName();
      }

      $product = $this->_getProduct();
      $collection = $product->getCollection()
      ->addAttributeToSelect('name')
      ->addAttributeToSelect('sku')
      ->addAttributeToSelect('attribute_set_id')
      ->addAttributeToSelect('type_id')
      ->addAttributeToSelect('price')
      ->addFieldToFilter('attribute_set_id',$product->getAttributeSetId())
      ->addFieldToFilter('type_id', $allowProductTypes)
      // ->addFilterByRequiredOptions()
      ->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'inner');

      if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
      Mage::getModel('cataloginventory/stock_item')->addCatalogInventoryToProductCollection($collection);
      }

      foreach ($product->getTypeInstance(true)->getUsedProductAttributes($product) as $attribute) {
      $collection->addAttributeToSelect($attribute->getAttributeCode());
      $collection->addAttributeToFilter($attribute->getAttributeCode(), array('notnull'=>1));
      }

      $this->setCollection($collection);

      if ($this->isReadonly()) {
      $collection->addFieldToFilter('entity_id', array('in' => $this->_getSelectedProducts()));
      }

      parent::_prepareCollection();
      return $this;
      }
      }


      in my config.xml I have this



          <?xml version="1.0"?>
      <config>
      <modules>
      <Ayasoftware_RequiredOptions>
      <version>0.1.0</version>
      </Ayasoftware_RequiredOptions>
      </modules>
      <global>
      <helpers>
      <requiredoptions>
      <class>Ayasoftware_RequiredOptions_Helper</class>
      </requiredoptions>
      </helpers>
      <blocks>
      <requiredoptions>
      <class>Ayasoftware_RequiredOptions_Block</class>
      </requiredoptions>
      <adminhtml>
      <rewrite>
      <catalog_product_edit_tab_super_config_grid>Ayasoftware_RequiredOptions_Block_Adminhtml_Catalog_Product_Edit_Tab_Super_Config_Grid</catalog_product_edit_tab_super_config_grid>
      </rewrite>
      </adminhtml>
      </blocks>
      <models>
      <requiredoptions>
      <class>Ayasoftware_RequiredOptions_Model</class>
      <resourceModel>requiredoptions_mysql4</resourceModel>
      </requiredoptions>

      </models>
      </global>
      </config>


      the function _prepareCollection is overridden correctly, but still using the original function that does not filter by ->addFilterByRequiredOptions()



      any idea how to fix this?
      was working fine in older versions.









      share














      I'm trying to override the function _prepareCollection in Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid class



          <?php
      class Ayasoftware_RequiredOptions_Block_Adminhtml_Catalog_Product_Edit_Tab_Super_Config_Grid extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid
      {
      protected function _prepareCollection()
      {
      echo "testing if overridden ";
      $allowProductTypes = array();
      foreach (Mage::helper('catalog/product_configuration')->getConfigurableAllowedTypes() as $type) {
      $allowProductTypes = $type->getName();
      }

      $product = $this->_getProduct();
      $collection = $product->getCollection()
      ->addAttributeToSelect('name')
      ->addAttributeToSelect('sku')
      ->addAttributeToSelect('attribute_set_id')
      ->addAttributeToSelect('type_id')
      ->addAttributeToSelect('price')
      ->addFieldToFilter('attribute_set_id',$product->getAttributeSetId())
      ->addFieldToFilter('type_id', $allowProductTypes)
      // ->addFilterByRequiredOptions()
      ->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'inner');

      if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
      Mage::getModel('cataloginventory/stock_item')->addCatalogInventoryToProductCollection($collection);
      }

      foreach ($product->getTypeInstance(true)->getUsedProductAttributes($product) as $attribute) {
      $collection->addAttributeToSelect($attribute->getAttributeCode());
      $collection->addAttributeToFilter($attribute->getAttributeCode(), array('notnull'=>1));
      }

      $this->setCollection($collection);

      if ($this->isReadonly()) {
      $collection->addFieldToFilter('entity_id', array('in' => $this->_getSelectedProducts()));
      }

      parent::_prepareCollection();
      return $this;
      }
      }


      in my config.xml I have this



          <?xml version="1.0"?>
      <config>
      <modules>
      <Ayasoftware_RequiredOptions>
      <version>0.1.0</version>
      </Ayasoftware_RequiredOptions>
      </modules>
      <global>
      <helpers>
      <requiredoptions>
      <class>Ayasoftware_RequiredOptions_Helper</class>
      </requiredoptions>
      </helpers>
      <blocks>
      <requiredoptions>
      <class>Ayasoftware_RequiredOptions_Block</class>
      </requiredoptions>
      <adminhtml>
      <rewrite>
      <catalog_product_edit_tab_super_config_grid>Ayasoftware_RequiredOptions_Block_Adminhtml_Catalog_Product_Edit_Tab_Super_Config_Grid</catalog_product_edit_tab_super_config_grid>
      </rewrite>
      </adminhtml>
      </blocks>
      <models>
      <requiredoptions>
      <class>Ayasoftware_RequiredOptions_Model</class>
      <resourceModel>requiredoptions_mysql4</resourceModel>
      </requiredoptions>

      </models>
      </global>
      </config>


      the function _prepareCollection is overridden correctly, but still using the original function that does not filter by ->addFilterByRequiredOptions()



      any idea how to fix this?
      was working fine in older versions.







      magento-1.9





      share












      share










      share



      share










      asked 2 mins ago









      MageDevBrossardMageDevBrossard

      438




      438






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f258388%2foverride-bloks-and-models-in-magento-1-9-4-0-is-not-working%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f258388%2foverride-bloks-and-models-in-magento-1-9-4-0-is-not-working%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Polycentropodidae

          Magento 2 Error message: Invalid state change requested

          Firearm provision in lease agreement