daily pastebin goal
61%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class Ayasoftware_RequiredOptions_Block_Adminhtml_Catalog_Product_Edit_Tab_Super_Config_Grid extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid
  3. {
  4.      protected function _prepareCollection()
  5.     {
  6.          echo "testing if overridden ";
  7.         $allowProductTypes = array();
  8.         foreach (Mage::helper('catalog/product_configuration')->getConfigurableAllowedTypes() as $type) {
  9.             $allowProductTypes[] = $type->getName();
  10.         }
  11.  
  12.         $product = $this->_getProduct();
  13.         $collection = $product->getCollection()
  14.             ->addAttributeToSelect('name')
  15.             ->addAttributeToSelect('sku')
  16.             ->addAttributeToSelect('attribute_set_id')
  17.             ->addAttributeToSelect('type_id')
  18.             ->addAttributeToSelect('price')
  19.             ->addFieldToFilter('attribute_set_id',$product->getAttributeSetId())
  20.             ->addFieldToFilter('type_id', $allowProductTypes)
  21.            // ->addFilterByRequiredOptions()
  22.             ->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'inner');
  23.  
  24.         if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
  25.             Mage::getModel('cataloginventory/stock_item')->addCatalogInventoryToProductCollection($collection);
  26.         }
  27.  
  28.         foreach ($product->getTypeInstance(true)->getUsedProductAttributes($product) as $attribute) {
  29.             $collection->addAttributeToSelect($attribute->getAttributeCode());
  30.             $collection->addAttributeToFilter($attribute->getAttributeCode(), array('notnull'=>1));
  31.         }
  32.  
  33.         $this->setCollection($collection);
  34.  
  35.         if ($this->isReadonly()) {
  36.             $collection->addFieldToFilter('entity_id', array('in' => $this->_getSelectedProducts()));
  37.         }
  38.  
  39.         parent::_prepareCollection();
  40.         return $this;
  41.     }
  42. }
  43.    
  44. <?xml version="1.0"?>
  45. <config>
  46.     <modules>
  47.         <Ayasoftware_RequiredOptions>
  48.             <version>0.1.0</version>
  49.         </Ayasoftware_RequiredOptions>
  50.     </modules>
  51.     <global>
  52.         <helpers>
  53.             <requiredoptions>
  54.                 <class>Ayasoftware_RequiredOptions_Helper</class>
  55.             </requiredoptions>
  56.         </helpers>
  57.         <blocks>
  58.             <requiredoptions>
  59.                 <class>Ayasoftware_RequiredOptions_Block</class>
  60.             </requiredoptions>
  61.             <adminhtml>
  62.                 <rewrite>
  63.                     <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>
  64.                 </rewrite>
  65.             </adminhtml>
  66.         </blocks>
  67.         <models>
  68.             <requiredoptions>
  69.                 <class>Ayasoftware_RequiredOptions_Model</class>
  70.                 <resourceModel>requiredoptions_mysql4</resourceModel>
  71.             </requiredoptions>
  72.  
  73.         </models>
  74.     </global>
  75. </config>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top