Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Webkul_Mpassignproduct_Block_Mpassignproduct extends Mage_Core_Block_Template
- {
- protected $_productsCollection = null;
- public function __construct(){
- parent::__construct();
- $filter = "";
- if(isset($_GET['q']))
- $filter = $_GET['q'] != ""?$_GET['q']:"";
- $sellerId = Mage::getSingleton('customer/session')->getCustomer()->getId();
- $marketplaceProductCollection = Mage::getModel('marketplace/product')->getCollection()
- ->addFieldToFilter('userid', array('eq' => $sellerId));
- $ids = array();
- foreach ($marketplaceProductCollection as $product) {
- $ids[] = $product->getMageproductid();
- }
- $collection = Mage::getModel('catalog/product')->getCollection()
- ->addAttributeToFilter('status', array('neq' => 2))
- ->addAttributeToSelect('*')
- ->addFieldToFilter('visibility',array('neq' => 1))
- ->addFieldToFilter('name',array('like' => "%".$filter."%"))
- ->setOrder('entity_id','AESC');
- if(!empty($ids))
- $collection->addAttributeToFilter('entity_id', array('nin' => $ids));
- $this->setCollection($collection);
- }
- protected function _prepareLayout() {
- parent::_prepareLayout();
- $pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
- $grid_per_page_values = explode(",",Mage::getStoreConfig('catalog/frontend/grid_per_page_values'));
- $arr_perpage = array();
- foreach ($grid_per_page_values as $value) {
- $arr_perpage[$value] = $value;
- }
- $pager->setAvailableLimit($arr_perpage);
- $pager->setCollection($this->getCollection());
- $this->setChild('pager', $pager);
- $this->getCollection()->load();
- return $this;
- }
- public function getPagerHtml() {
- return $this->getChildHtml('pager');
- }
- }
Add Comment
Please, Sign In to add comment