Example #1
0
 /**
  * Return items collection
  *
  * @return Mage_Core_Model_Mysql4_Collection_Abstract
  */
 public function getItemsCollection()
 {
     if (!$this->hasData('items_collection')) {
         $wishlist = Mage::getModel('wishlist/wishlist')->loadByCustomer($this->_getCustomer())->setStore($this->_getStore())->setSharedStoreIds($this->_getStore()->getWebsite()->getStoreIds());
         if ($wishlist->getId()) {
             $collection = $wishlist->getProductCollection()->resetSortOrder()->addAttributeToSelect('name')->addAttributeToSelect('price');
             $collection = Mage::helper('adminhtml/sales')->applySalableProductTypesFilter($collection);
         } else {
             $collection = parent::getItemsCollection();
         }
         $this->setData('items_collection', $collection);
     }
     return $this->_getData('items_collection');
 }
Example #2
0
 /**
  * Prepare customer wishlist product collection
  *
  * @return Mage_Adminhtml_Block_Customer_Edit_Tab_Wishlist
  */
 public function getItemsCollection()
 {
     if (!$this->hasData('items_collection')) {
         $collection = Mage::getModel('reports/event')->getCollection()->addStoreFilter($this->_getStore()->getWebsite()->getStoreIds())->addRecentlyFiler(Mage_Reports_Model_Event::EVENT_PRODUCT_VIEW, $this->_getCustomer()->getId(), 0);
         $productIds = array();
         foreach ($collection as $event) {
             $productIds[] = $event->getObjectId();
         }
         $productCollection = parent::getItemsCollection();
         if ($productIds) {
             $productCollection = Mage::getModel('catalog/product')->getCollection()->setStoreId($this->_getStore()->getId())->addStoreFilter($this->_getStore()->getId())->addAttributeToSelect('name')->addAttributeToSelect('price')->addIdFilter($productIds)->load();
             $productCollection = Mage::helper('adminhtml/sales')->applySalableProductTypesFilter($productCollection);
         }
         $this->setData('items_collection', $productCollection);
     }
     return $this->_getData('items_collection');
 }
Example #3
0
 /**
  * Prepare customer wishlist product collection
  *
  * @return Mage_Core_Model_Resource_Db_Collection_Abstract
  */
 public function getItemsCollection()
 {
     if (!$this->hasData('items_collection')) {
         $collection = Mage::getModel('reports/event')->getCollection()->addStoreFilter($this->_getStore()->getWebsite()->getStoreIds())->addRecentlyFiler(Mage_Reports_Model_Event::EVENT_PRODUCT_VIEW, $this->_getCustomer()->getId(), 0);
         $productIds = array();
         foreach ($collection as $event) {
             $productIds[] = $event->getObjectId();
         }
         $productCollection = parent::getItemsCollection();
         if ($productIds) {
             $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
             $productCollection = Mage::getModel('catalog/product')->getCollection()->setStoreId($this->_getStore()->getId())->addStoreFilter($this->_getStore()->getId())->addAttributeToSelect($attributes)->addIdFilter($productIds)->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
             Mage::getSingleton('cataloginventory/stock_status')->addIsInStockFilterToCollection($productCollection);
             $productCollection = Mage::helper('adminhtml/sales')->applySalableProductTypesFilter($productCollection);
             $productCollection->addOptionsToResult();
         }
         $this->setData('items_collection', $productCollection);
     }
     return $this->_getData('items_collection');
 }
Example #4
0
 /**
  * Prepare customer wishlist product collection
  *
  * @return Mage_Adminhtml_Block_Customer_Edit_Tab_Wishlist
  */
 public function getItemsCollection()
 {
     if (!$this->hasData('items_collection')) {
         $storeIds = $this->_getStore()->getWebsite()->getStoreIds();
         /* @var $collection Mage_Core_Model_Mysql4_Collection_Abstract */
         $collection = Mage::getResourceModel('sales/order_collection')->addAttributeToFilter('customer_id', $this->_getCustomer()->getId())->addAttributeToFilter('store_id', array('in' => $storeIds))->addAttributeToSort('created_at', 'desc')->setPage(1, 1)->load();
         foreach ($collection as $order) {
             break;
         }
         if (isset($order)) {
             $collection = $order->getItemsCollection();
             foreach ($collection as $item) {
                 if ($item->getParentItem()) {
                     $collection->removeItemByKey($item->getId());
                 }
             }
         }
         if (isset($order)) {
             $collection = Mage::helper('adminhtml/sales')->applySalableProductTypesFilter($collection);
         }
         $this->setData('items_collection', isset($order) ? $collection : parent::getItemsCollection());
     }
     return $this->getData('items_collection');
 }
Example #5
0
 /**
  * Prepare customer wishlist product collection
  *
  * @return Mage_Core_Model_Resource_Db_Collection_Abstract
  */
 public function getItemsCollection()
 {
     if (!$this->hasData('items_collection')) {
         $productIds = array();
         $storeIds = $this->_getStore()->getWebsite()->getStoreIds();
         // Load last order of a customer
         /* @var $collection Mage_Core_Model_Mysql4_Collection_Abstract */
         $collection = Mage::getResourceModel('sales/order_collection')->addAttributeToFilter('customer_id', $this->_getCustomer()->getId())->addAttributeToFilter('store_id', array('in' => $storeIds))->addAttributeToSort('created_at', 'desc')->setPage(1, 1)->load();
         foreach ($collection as $order) {
             break;
         }
         // Add products to order items
         if (isset($order)) {
             $productIds = array();
             $collection = $order->getItemsCollection();
             foreach ($collection as $item) {
                 if ($item->getParentItem()) {
                     $collection->removeItemByKey($item->getId());
                 } else {
                     $productIds[$item->getProductId()] = $item->getProductId();
                 }
             }
             if ($productIds) {
                 // Load products collection
                 $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
                 $products = Mage::getModel('catalog/product')->getCollection()->setStore($this->_getStore())->addAttributeToSelect($attributes)->addAttributeToSelect('sku')->addAttributeToFilter('type_id', array_keys(Mage::getConfig()->getNode('adminhtml/sales/order/create/available_product_types')->asArray()))->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->addStoreFilter($this->_getStore())->addIdFilter($productIds);
                 Mage::getSingleton('cataloginventory/stock_status')->addIsInStockFilterToCollection($products);
                 Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($products);
                 $products->addOptionsToResult();
                 // Set products to items
                 foreach ($collection as $item) {
                     $productId = $item->getProductId();
                     $product = $products->getItemById($productId);
                     if ($product) {
                         $item->setProduct($product);
                     } else {
                         $collection->removeItemByKey($item->getId());
                     }
                 }
             }
         }
         $this->setData('items_collection', $productIds ? $collection : parent::getItemsCollection());
     }
     return $this->getData('items_collection');
 }
 public function __construct()
 {
     parent::__construct();
     $this->setId('source_compared');
     $this->setHeaderText(Mage::helper('enterprise_checkout')->__('Products in the Comparison List (%s)', $this->getItemsCount()));
 }
 protected function _afterLoadCollection()
 {
     $this->getCollection()->addOptionsToResult();
     return parent::_afterLoadCollection();
 }
Example #8
0
 /**
  * Add columns with controls to manage added products and their quantity
  * Uses inherited methods, but modifies Qty column to change renderer
  *
  * @return Enterprise_Checkout_Block_Adminhtml_Manage_Accordion_Wishlist
  */
 protected function _addControlColumns()
 {
     parent::_addControlColumns();
     $this->addColumn('qty', array('sortable' => false, 'header' => Mage::helper('enterprise_checkout')->__('Qty To Add'), 'renderer' => 'enterprise_checkout/adminhtml_manage_grid_renderer_wishlist_qty', 'name' => 'qty', 'inline_css' => 'qty', 'align' => 'right', 'type' => 'input', 'validate_class' => 'validate-number', 'index' => 'qty', 'width' => '1'));
     return $this;
 }
Example #9
0
 /**
  * Search by selected products
  *
  * @return Mage_Adminhtml_Block_Widget_Grid
  */
 protected function _addColumnFilterToCollection($column)
 {
     // Set custom filter for in product flag
     if ($column->getId() == 'in_products') {
         $productIds = $this->_getSelectedProducts();
         if (!$productIds) {
             $productIds = 0;
         }
         if ($column->getFilter()->getValue()) {
             $this->getCollection()->addFieldToFilter('entity_id', array('in' => $productIds));
         } elseif ($productIds) {
             $this->getCollection()->addFieldToFilter('entity_id', array('nin' => $productIds));
         }
     } else {
         parent::_addColumnFilterToCollection($column);
     }
     return $this;
 }