Guest User

mpassignproduct.php

a guest
Apr 12th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1.  
  2. <?php
  3. class Webkul_Mpassignproduct_Block_Mpassignproduct extends Mage_Core_Block_Template
  4. {
  5. protected $_productsCollection = null;
  6. public function __construct(){
  7. parent::__construct();
  8. $filter = "";
  9. if(isset($_GET['q']))
  10. $filter = $_GET['q'] != ""?$_GET['q']:"";
  11. $sellerId = Mage::getSingleton('customer/session')->getCustomer()->getId();
  12. $marketplaceProductCollection = Mage::getModel('marketplace/product')->getCollection()
  13. ->addFieldToFilter('userid', array('eq' => $sellerId));
  14. $ids = array();
  15. foreach ($marketplaceProductCollection as $product) {
  16. $ids[] = $product->getMageproductid();
  17. }
  18. $collection = Mage::getModel('catalog/product')->getCollection()
  19. ->addAttributeToFilter('status', array('neq' => 2))
  20. ->addAttributeToSelect('*')
  21. ->addFieldToFilter('visibility',array('neq' => 1))
  22. ->addFieldToFilter('name',array('like' => "%".$filter."%"))
  23. ->setOrder('entity_id','AESC');
  24. if(!empty($ids))
  25. $collection->addAttributeToFilter('entity_id', array('nin' => $ids));
  26. $this->setCollection($collection);
  27. }
  28. protected function _prepareLayout() {
  29. parent::_prepareLayout();
  30. $pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
  31. $grid_per_page_values = explode(",",Mage::getStoreConfig('catalog/frontend/grid_per_page_values'));
  32. $arr_perpage = array();
  33. foreach ($grid_per_page_values as $value) {
  34. $arr_perpage[$value] = $value;
  35. }
  36. $pager->setAvailableLimit($arr_perpage);
  37. $pager->setCollection($this->getCollection());
  38. $this->setChild('pager', $pager);
  39. $this->getCollection()->load();
  40. return $this;
  41. }
  42.  
  43. public function getPagerHtml() {
  44. return $this->getChildHtml('pager');
  45. }
  46. }
Add Comment
Please, Sign In to add comment