loadLayout(); $this->renderLayout(); } /** * Grid action */ public function gridAction() { $this->loadLayout(); $this->getResponse()->setBody($this->getLayout()->createBlock('find_feed/adminhtml_list_items_grid')->toHtml()); } /** * Product list for mass action * * @return array */ protected function _getMassActionProducts() { $idList = $this->getRequest()->getParam('item_id'); if (!empty($idList)) { $products = array(); foreach ($idList as $id) { $model = Mage::getModel('catalog/product'); if ($model->load($id)) { array_push($products, $model); } } return $products; } else { return array(); } } /** * Add product to feed mass action */ public function massEnableAction() { $idList = $this->getRequest()->getParam('item_id'); $updateAction = Mage::getModel('catalog/product_action'); $attrData = array( 'is_imported' => 1 ); $updatedProducts = count($idList); if ($updatedProducts) { try { $updateAction->updateAttributes($idList, $attrData, Mage::app()->getStore()->getId()); Mage::getModel('find_feed/import')->processImport(); $this->_getSession()->addSuccess(Mage::helper('find_feed')->__("%s product in feed.", $updatedProducts)); } catch (Exception $e) { $this->_getSession()->addError(Mage::helper('find_feed')->__("Unable to process an import. ") . $e->getMessage()); } } $this->_redirect('*/*/index'); } /** * Not add product to feed mass action */ public function massDisableAction() { $updatedProducts = 0; foreach ($this->_getMassActionProducts() as $product) { $product->setIsImported(0); $product->save(); $updatedProducts++; } if ($updatedProducts) { Mage::getModel('find_feed/import')->processImport(); $this->_getSession()->addSuccess(Mage::helper('find_feed')->__("%s product not in feed.", $updatedProducts)); } $this->_redirect('*/*/index'); } }