/**
  * Add filtration by customer id
  *
  * @param int $customerId
  * @return Enterprise_Wishlist_Model_Resource_Item_Collection
  */
 public function addCustomerIdFilter($customerId)
 {
     parent::addCustomerIdFilter($customerId);
     $adapter = $this->getConnection();
     $defaultWishlistName = Mage::helper('wishlist')->getDefaultWishlistName();
     $this->getSelect()->columns(array('wishlist_name' => $adapter->getIfNullSql('wishlist.name', $adapter->quote($defaultWishlistName))));
     $this->addFilterToMap('wishlist_name', $adapter->getIfNullSql('wishlist.name', $adapter->quote($defaultWishlistName)));
     return $this;
 }
示例#2
0
 /**
  * Add sidebar conditions to collection
  *
  * @param  Mage_Wishlist_Model_Resource_Item_Collection $collection
  * @return Mage_Wishlist_Block_Customer_Wishlist
  */
 protected function _prepareCollection($collection)
 {
     $collection->setCurPage(1)->setPageSize(3)->setInStockFilter(true)->setOrder('added_at');
     return $this;
 }
示例#3
0
 /**
  * Inner join the groupscatalog index table to hide wishlist items whose
  * products are not visible to the specified customer group id
  *
  * @param Mage_Wishlist_Model_Resource_Item_Collection $collection
  * @param int $groupId
  * @param int $storeId
  * @return void
  */
 public function addGroupsCatalogFilterToWishlistItemCollection(Mage_Wishlist_Model_Resource_Item_Collection $collection, $groupId, $storeId)
 {
     /* @var $helper Netzarbeiter_GroupsCatalog2_Helper_Data */
     $helper = Mage::helper('netzarbeiter_groupscatalog2');
     // Switch index table depending on the specified entity
     $this->_init($helper->getIndexTableByEntityType(Mage_Catalog_Model_Product::ENTITY), 'id');
     if ($this->_doesIndexExists()) {
         $table = $this->getTable($helper->getIndexTableByEntityType(Mage_Catalog_Model_Product::ENTITY));
         $this->_addGroupsCatalogFilterToSelect($collection->getSelect(), $table, $groupId, $storeId, 'main_table.product_id');
     }
 }
示例#4
0
 /**
  * Add field filter to collection
  *
  * @see self::_getConditionSql for $condition
  *
  * @param string|array $field
  * @param null|string|array $condition
  * @return Varien_Data_Collection_Db
  */
 public function addFieldToFilter($field, $condition = null)
 {
     switch ($field) {
         case 'product_name':
             $value = (string) $condition['like'];
             $value = trim(trim($value, "'"), "%");
             return $this->addProductNameFilter($value);
         case 'store_id':
             if (isset($condition['eq'])) {
                 return $this->addStoreFilter($condition);
             }
             break;
         case 'days_in_wishlist':
             if (!isset($condition['datetime'])) {
                 return $this->addDaysFilter($condition);
             }
     }
     return parent::addFieldToFilter($field, $condition);
 }
示例#5
0
 /**
  * Add wishlist conditions to collection
  *
  * @param  Mage_Wishlist_Model_Resource_Item_Collection $collection
  * @return Mage_Wishlist_Block_Customer_Wishlist
  */
 protected function _prepareCollection($collection)
 {
     $collection->setInStockFilter(true)->setOrder('added_at', 'ASC');
     return $this;
 }
示例#6
0
 /**
  * Set order to result
  *
  * @param string $attribute
  * @param string $dir
  * @return Mage_Reports_Model_Resource_Wishlist_Product_Collection
  */
 public function setOrder($attribute, $dir = self::SORT_ORDER_DESC)
 {
     if ($attribute == 'wishlists') {
         $this->getSelect()->order($attribute . ' ' . $dir);
     } else {
         parent::setOrder($attribute, $dir);
     }
     return $this;
 }
示例#7
0
 /**
  * Inner join the groupscatalog index table to hide wishlist items whose
  * products are not visible to the specified customer group id
  *
  * @param Mage_Wishlist_Model_Resource_Item_Collection $collection
  * @param int $groupId
  * @param int $storeId
  * @return void
  */
 public function addGroupsCatalogFilterToWishlistItemCollection(Mage_Wishlist_Model_Resource_Item_Collection $collection, $groupId, $storeId)
 {
     $select = $collection->getSelect();
     $entityField = 'main_table.product_id';
     $this->addGroupsCatalogProductFilterToSelect($select, $groupId, $storeId, $entityField);
 }