/** * Enter description here... * * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection * @return Mage_Catalog_Model_Layer */ public function prepareProductCollection($collection) { $collection->addAttributeToSelect('name')->addAttributeToSelect('url_key')->addAttributeToSelect('price')->addAttributeToSelect('special_price')->addAttributeToSelect('special_from_date')->addAttributeToSelect('special_to_date')->joinMinimalPrice()->addAttributeToSelect('description')->addAttributeToSelect('short_description')->addAttributeToSelect('image')->addAttributeToSelect('thumbnail')->addAttributeToSelect('small_image')->addAttributeToSelect('tax_class_id')->addStoreFilter(); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); return $this; }
/** * Prepare product collection * * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection * @return Mage_Catalog_Model_Layer */ public function prepareProductCollection($collection) { $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addSearchFilter(Mage::helper('catalogsearch')->getQuery()->getQueryText())->setStore(Mage::app()->getStore())->addMinimalPrice()->addFinalPrice()->addTaxPercents()->addStoreFilter()->addUrlRewrite(); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection); return $this; }
function doCollection() { $collection = new Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection(); $collection->setStoreId(Mage::app()->getStore()->getId()); $collection->addAttributeToSelect('*'); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); // Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); return $collection; }
/** * Collect validated attributes * * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $productCollection * @return Mage_CatalogRule_Model_Rule_Condition_Product */ public function collectValidatedAttributes($productCollection) { $attribute = $this->getAttribute(); if ($attribute == 'category_ids' || $this->isFilterCustom($attribute)) { return $this; } if ($this->getAttributeObject()->isScopeGlobal()) { $attributes = $this->getRule()->getCollectedAttributes(); $attributes[$attribute] = true; $this->getRule()->setCollectedAttributes($attributes); $productCollection->addAttributeToSelect($attribute, 'left'); } else { $this->_entityAttributeValues = $productCollection->getAllAttributeValues($attribute); } return $this; }
/** * Filter product collection * * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection * @return Mage_Catalog_Model_Layer */ public function prepareProductCollection($collection) { $rule = $this->getRule(); if ($rule->getData('show_outofstock') == 2) { $collection->joinField('stock_status', 'cataloginventory/stock_status', 'stock_status', 'product_id=entity_id', array('stock_status' => Mage_CatalogInventory_Model_Stock_Status::STATUS_IN_STOCK, 'website_id' => Mage::app()->getWebsite()->getWebsiteId())); } $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addMinimalPrice()->addFinalPrice()->addTaxPercents(); /*Filter min, max price*/ $this->currentRate = Mage::app()->getStore()->getCurrentCurrencyRate(); $max = $this->getMaxPriceFilter(); $min = $this->getMinPriceFilter(); if ($min && $max) { $collection->getSelect()->where(' final_price >= "' . $min . '" AND final_price <= "' . $max . '" '); } /*End Filter min, max price*/ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); //$this->_productCollections = $collection; return $this; }
/** * Initialize product collection * * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection * @return Mage_Catalog_Model_Layer */ public function prepareProductCollection($collection) { $collection ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes()) ->addMinimalPrice() ->addFinalPrice() ->addTaxPercents() ->addUrlRewrite($this->getCurrentCategory()->getId()); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); return $this; }
/** * Initialize product collection * * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection * @return Mage_Catalog_Model_Layer */ public function prepareProductCollection($collection) { if (strtolower($this->getCurrentCategory()->getName()) == "new arrivals") { $todayDate = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())); //$date_band = Mage::getStoreConfig("inventory/date_setting/old_after"); /* if($date_band == ""){ $date_band = 100; } */ $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addMinimalPrice()->addFinalPrice()->addTaxPercents()->addUrlRewrite($this->getCurrentCategory()->getId())->addAttributeToFilter('news_from_date', array('lteq' => $todayDate)); //$collection->getSelect()->where("DATE_ADD(`at_news_from_date_default`.value,INTERVAL ".$date_band." DAY) >= ?",$todayDate); } else { $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addMinimalPrice()->addFinalPrice()->addTaxPercents()->addUrlRewrite($this->getCurrentCategory()->getId()); } Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); return $this; }
/** * Collect validated attributes * * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $productCollection * @return Mage_CatalogRule_Model_Rule_Condition_Product */ public function collectValidatedAttributes($productCollection) { if ($this->getAttribute() == 'category_ids') { return $this; } $attributes = $this->getRule()->getCollectedAttributes(); $attributes[$this->getAttribute()] = true; $this->getRule()->setCollectedAttributes($attributes); $productCollection->addAttributeToSelect($this->getAttribute(), 'left'); return $this; }
/** * Initialize product collection * * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection * @return Mage_Catalog_Model_Layer */ public function prepareProductCollection($collection) { $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addMinimalPrice()->addFinalPrice()->addTaxPercents()->addUrlRewrite($this->getCurrentCategory()->getId()); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); //Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); $collection->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH); //$collection->addAttributeToFilter('sku', array('eq' => 'TTE7QSA43')); return $this; }
/** * Initialize product collection * * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection * @return Mage_Catalog_Model_Layer */ public function prepareProductCollection($collection) { $session = Mage::getSingleton('customer/session'); $isCorporate = FALSE; if ($session->isLoggedIn()) { $customer = $session->getCustomer(); $isCorporate = $customer->getZiscorporate(); } $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addMinimalPrice()->addFinalPrice()->addTaxPercents()->addUrlRewrite($this->getCurrentCategory()->getId()); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); if ($isCorporate != 470) { Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); } return $this; }