php - Magento/Adminhtml - Receiving error while trying to search for custom column in products grid -


this adminhtml products grid.php:

class mage_adminhtml_block_catalog_product_grid extends mage_adminhtml_block_widget_grid {      public function __construct()     {         parent::__construct();         $this->setid('productgrid');         $this->setdefaultsort('entity_id');         $this->setdefaultdir('desc');         $this->setsaveparametersinsession(true);         $this->setuseajax(true);         $this->setvarnamefilter('product_filter');      }      protected function _getstore()     {         $storeid = (int) $this->getrequest()->getparam('store', 0);         return mage::app()->getstore($storeid);     }      protected function _preparecollection()     {         $store = $this->_getstore();         $collection = mage::getmodel('catalog/product')->getcollection()             ->addattributetoselect('sku')             ->addattributetoselect('name')             ->addattributetoselect('attribute_set_id')             ->addattributetoselect('type_id');          if (mage::helper('catalog')->ismoduleenabled('mage_cataloginventory')) {             $collection->joinfield('qty',                 'cataloginventory/stock_item',                 'qty',                 'product_id=entity_id',                 '{{table}}.stock_id=1',                 'left');         }         if ($store->getid()) {             //$collection->setstoreid($store->getid());             $adminstore = mage_core_model_app::admin_store_id;             $collection->addstorefilter($store);             $collection->joinattribute(                 'name',                 'catalog_product/name',                 'entity_id',                 null,                 'inner',                 $adminstore             );             $collection->joinattribute(                 'custom_name',                 'catalog_product/name',                 'entity_id',                 null,                 'inner',                 $store->getid()             );             $collection->joinattribute(                 'status',                 'catalog_product/status',                 'entity_id',                 null,                 'inner',                 $store->getid()             );             $collection->joinattribute(                 'visibility',                 'catalog_product/visibility',                 'entity_id',                 null,                 'inner',                 $store->getid()             );             $collection->joinattribute(                 'price',                 'catalog_product/price',                 'entity_id',                 null,                 'left',                 $store->getid()             );         }         else {             $collection->addattributetoselect('price');             $collection->joinattribute('status', 'catalog_product/status', 'entity_id', null, 'inner');             $collection->joinattribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');         }          $collection->getselect()->joinleft(          array('order_item'=>'sales_flat_order_item'),         'e.entity_id = order_item.product_id',          array('order_item.product_id','order_item.order_id')         );         $collection->getselect()->joinleft(                  array('order'=>'sales_flat_order'),                 'order_item.order_id = `order`.entity_id',                  array('order.increment_id')                 );         $collection->getselect()->group('e.entity_id');           $this->setcollection($collection);          parent::_preparecollection();         $this->getcollection()->addwebsitenamestoresult();         return $this;     }      protected function _addcolumnfiltertocollection($column)     {         if ($this->getcollection()) {             if ($column->getid() == 'websites') {                 $this->getcollection()->joinfield('websites',                     'catalog/product_website',                     'website_id',                     'product_id=entity_id',                     null,                     'left');             }         }         return parent::_addcolumnfiltertocollection($column);     }      protected function _preparecolumns()     {         $this->addcolumn('entity_id',             array(                 'header'=> mage::helper('catalog')->__('id'),                 'width' => '50px',                 'type'  => 'number',                 'index' => 'entity_id',         ));         $this->addcolumn('name',             array(                 'header'=> mage::helper('catalog')->__('name'),                 'index' => 'name',         ));          $store = $this->_getstore();         if ($store->getid()) {             $this->addcolumn('custom_name',                 array(                     'header'=> mage::helper('catalog')->__('name in %s', $store->getname()),                     'index' => 'custom_name',             ));         }          $this->addcolumn('type',             array(                 'header'=> mage::helper('catalog')->__('type'),                 'width' => '60px',                 'index' => 'type_id',                 'type'  => 'options',                 'options' => mage::getsingleton('catalog/product_type')->getoptionarray(),         ));          $sets = mage::getresourcemodel('eav/entity_attribute_set_collection')             ->setentitytypefilter(mage::getmodel('catalog/product')->getresource()->gettypeid())             ->load()             ->tooptionhash();          $this->addcolumn('set_name',             array(                 'header'=> mage::helper('catalog')->__('attrib. set name'),                 'width' => '100px',                 'index' => 'attribute_set_id',                 'type'  => 'options',                 'options' => $sets,         ));          $this->addcolumn('sku',             array(                 'header'=> mage::helper('catalog')->__('sku'),                 'width' => '80px',                 'index' => 'sku',         ));          $this->addcolumn('increment_id',             array(                 'header'=> mage::helper('catalog')->__('Поръчка №'),                 'width' => '100px',                 'index' => 'increment_id',         ));          $store = $this->_getstore();         $this->addcolumn('price',             array(                 'header'=> mage::helper('catalog')->__('price'),                 'type'  => 'price',                 'currency_code' => $store->getbasecurrency()->getcode(),                 'index' => 'price',         ));          if (mage::helper('catalog')->ismoduleenabled('mage_cataloginventory')) {             $this->addcolumn('qty',                 array(                     'header'=> mage::helper('catalog')->__('qty'),                     'width' => '100px',                     'type'  => 'number',                     'index' => 'qty',             ));         }          $this->addcolumn('visibility',             array(                 'header'=> mage::helper('catalog')->__('visibility'),                 'width' => '70px',                 'index' => 'visibility',                 'type'  => 'options',                 'options' => mage::getmodel('catalog/product_visibility')->getoptionarray(),         ));          $this->addcolumn('status',             array(                 'header'=> mage::helper('catalog')->__('status'),                 'width' => '70px',                 'index' => 'status',                 'type'  => 'options',                 'options' => mage::getsingleton('catalog/product_status')->getoptionarray(),         ));          if (!mage::app()->issinglestoremode()) {             $this->addcolumn('websites',                 array(                     'header'=> mage::helper('catalog')->__('websites'),                     'width' => '100px',                     'sortable'  => false,                     'index'     => 'websites',                     'type'      => 'options',                     'options'   => mage::getmodel('core/website')->getcollection()->tooptionhash(),             ));         }          $this->addcolumn('action',             array(                 'header'    => mage::helper('catalog')->__('action'),                 'width'     => '50px',                 'type'      => 'action',                 'getter'     => 'getid',                 'actions'   => array(                     array(                         'caption' => mage::helper('catalog')->__('edit'),                         'url'     => array(                             'base'=>'*/*/edit',                             'params'=>array('store'=>$this->getrequest()->getparam('store'))                         ),                         'field'   => 'id'                     )                 ),                 'filter'    => false,                 'sortable'  => false,                 'index'     => 'stores',         ));          if (mage::helper('catalog')->ismoduleenabled('mage_rss')) {             $this->addrsslist('rss/catalog/notifystock', mage::helper('catalog')->__('notify low stock rss'));         }          return parent::_preparecolumns();     }      protected function _preparemassaction()     {         $this->setmassactionidfield('entity_id');         $this->getmassactionblock()->setformfieldname('product');          $this->getmassactionblock()->additem('delete', array(              'label'=> mage::helper('catalog')->__('delete'),              'url'  => $this->geturl('*/*/massdelete'),              'confirm' => mage::helper('catalog')->__('are sure?')         ));          $statuses = mage::getsingleton('catalog/product_status')->getoptionarray();          array_unshift($statuses, array('label'=>'', 'value'=>''));         $this->getmassactionblock()->additem('status', array(              'label'=> mage::helper('catalog')->__('change status'),              'url'  => $this->geturl('*/*/massstatus', array('_current'=>true)),              'additional' => array(                     'visibility' => array(                          'name' => 'status',                          'type' => 'select',                          'class' => 'required-entry',                          'label' => mage::helper('catalog')->__('status'),                          'values' => $statuses                      )              )         ));          if (mage::getsingleton('admin/session')->isallowed('catalog/update_attributes')){             $this->getmassactionblock()->additem('attributes', array(                 'label' => mage::helper('catalog')->__('update attributes'),                 'url'   => $this->geturl('*/catalog_product_action_attribute/edit', array('_current'=>true))             ));         }          mage::dispatchevent('adminhtml_catalog_product_grid_prepare_massaction', array('block' => $this));         return $this;     }      public function getgridurl()     {         return $this->geturl('*/*/grid', array('_current'=>true));     }      public function getrowurl($row)     {         return $this->geturl('*/*/edit', array(             'store'=>$this->getrequest()->getparam('store'),             'id'=>$row->getid())         );     } } 

with code adding new column products grid display increcement order id in order product present.

in our store 1 product can't present in more 1 order.

so here how looks:

enter image description here

everything fine. problem comes when try search in grid order increcement id. receive following error:

fatal error: call member function getbackend() on non-object in /var/sentora/hostdata/zadmin/public_html/dev_sportsdirect_bg/app/code/core/mage/eav/model/entity/abstract.php on line 816

where mistake , why search not working? want when enter order increcement id in adminhtml product grid , initiate search display products included in order increcement id making search.

i hope have explained well.

looking forward , answers.

kind regards.

 $this->addcolumn('increment_id',      array(          'header'=> mage::helper('catalog')->__('Поръчка №'),          'width' => '100px',          'index' => 'order.increment_id', )); 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -