コード例 #1
0
ファイル: Giveaway.php プロジェクト: sitewards/giveaway
 /**
  * Retrieve loaded Giveaway Product Collection
  *
  * @return Mage_Eav_Model_Entity_Collection_Abstract
  */
 protected function _getGiveawayCollection()
 {
     if (is_null($this->_productCollection)) {
         $oProduct = Mage::getModel('catalog/product');
         /* @var $oCollection Mage_Catalog_Model_Resource_Product_Collection */
         $this->_productCollection = $oProduct->getResourceCollection();
         $oSitewardsGiveawayHelper = Mage::helper('sitewards_giveaway');
         $sGiveawayAttributeCode = $oSitewardsGiveawayHelper->getGiveawayIdentifierName();
         $this->_productCollection->addAttributeToFilter($sGiveawayAttributeCode, true);
         $this->_productCollection->addAttributeToSelect('*');
     }
     return $this->_productCollection;
 }
コード例 #2
0
 /**
  * Apply filter to collection and add not skipped attributes to select.
  *
  * @param Mage_Eav_Model_Entity_Collection_Abstract $collection
  * @return Mage_Eav_Model_Entity_Collection_Abstract
  */
 protected function _prepareEntityCollection(Mage_Eav_Model_Entity_Collection_Abstract $collection)
 {
     if (!isset($this->_parameters[Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP]) || !is_array($this->_parameters[Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP])) {
         $exportFilter = array();
     } else {
         $exportFilter = $this->_parameters[Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP];
     }
     $exportAttrCodes = $this->_getExportAttrCodes();
     foreach ($this->filterAttributeCollection($this->getAttributeCollection()) as $attribute) {
         $attrCode = $attribute->getAttributeCode();
         // filter applying
         if (isset($exportFilter[$attrCode])) {
             $attrFilterType = Mage_ImportExport_Model_Export::getAttributeFilterType($attribute);
             if ($attrCode == 'sku') {
                 $collection->addAttributeToFilter($attrCode, array('in' => $exportFilter[$attrCode]));
             } elseif (Mage_ImportExport_Model_Export::FILTER_TYPE_SELECT == $attrFilterType) {
                 if (is_scalar($exportFilter[$attrCode]) && trim($exportFilter[$attrCode])) {
                     $collection->addAttributeToFilter($attrCode, array('eq' => $exportFilter[$attrCode]));
                 }
             } elseif (Mage_ImportExport_Model_Export::FILTER_TYPE_INPUT == $attrFilterType) {
                 if (is_scalar($exportFilter[$attrCode]) && trim($exportFilter[$attrCode])) {
                     $collection->addAttributeToFilter($attrCode, array('like' => "%{$exportFilter[$attrCode]}%"));
                 }
             } elseif (Mage_ImportExport_Model_Export::FILTER_TYPE_DATE == $attrFilterType) {
                 if (is_array($exportFilter[$attrCode]) && count($exportFilter[$attrCode]) == 2) {
                     $from = array_shift($exportFilter[$attrCode]);
                     $to = array_shift($exportFilter[$attrCode]);
                     if (is_scalar($from) && !empty($from)) {
                         $date = Mage::app()->getLocale()->date($from, null, null, false)->toString('MM/dd/YYYY');
                         $collection->addAttributeToFilter($attrCode, array('from' => $date, 'date' => true));
                     }
                     if (is_scalar($to) && !empty($to)) {
                         $date = Mage::app()->getLocale()->date($to, null, null, false)->toString('MM/dd/YYYY');
                         $collection->addAttributeToFilter($attrCode, array('to' => $date, 'date' => true));
                     }
                 }
             } elseif (Mage_ImportExport_Model_Export::FILTER_TYPE_NUMBER == $attrFilterType) {
                 if (is_array($exportFilter[$attrCode]) && count($exportFilter[$attrCode]) == 2) {
                     $from = array_shift($exportFilter[$attrCode]);
                     $to = array_shift($exportFilter[$attrCode]);
                     if (is_numeric($from)) {
                         $collection->addAttributeToFilter($attrCode, array('from' => $from));
                     }
                     if (is_numeric($to)) {
                         $collection->addAttributeToFilter($attrCode, array('to' => $to));
                     }
                 }
             }
         }
         if (in_array($attrCode, $exportAttrCodes)) {
             $collection->addAttributeToSelect($attrCode);
         }
     }
     return $collection;
 }
コード例 #3
0
ファイル: Specials.php プロジェクト: amal-nibaya/PB-BEERSHOP
 /**
  * Retrieve loaded category collection
  *
  * @return Mage_Eav_Model_Entity_Collection_Abstract
  */
 protected function _getProductCollection()
 {
     if (is_null($this->_productCollection)) {
         $layer = $this->getLayer();
         /* @var $layer Mage_Catalog_Model_Layer */
         if ($this->getShowRootCategory()) {
             $this->setCategoryId(Mage::app()->getStore()->getRootCategoryId());
         }
         // if this is a product view page
         if (Mage::registry('product')) {
             // get collection of categories this product is associated with
             $categories = Mage::registry('product')->getCategoryCollection()->setPage(1, 1)->load();
             // if the product is associated with any category
             if ($categories->count()) {
                 // show products from this category
                 $this->setCategoryId(current($categories->getIterator()));
             }
         }
         $origCategory = null;
         if ($this->getCategoryId()) {
             $category = Mage::getModel('catalog/category')->load($this->getCategoryId());
             if ($category->getId()) {
                 $origCategory = $layer->getCurrentCategory();
                 $layer->setCurrentCategory($category);
             }
         }
         $this->_productCollection = $layer->getProductCollection();
         $dateToday = date('m/d/y');
         $dateToday = date('m/d/y');
         $tomorrow = mktime(0, 0, 0, date('m'), date('d') + 1, date('y'));
         $dateTomorrow = date('m/d/y', $tomorrow);
         $this->_productCollection->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $dateToday))->addAttributeToFilter('special_to_date', array('or' => array(0 => array('date' => true, 'from' => $dateTomorrow), 1 => array('is' => new Zend_Db_Expr('null')))), 'left');
         $this->prepareSortableFieldsByCategory($layer->getCurrentCategory());
         if ($origCategory) {
             $layer->setCurrentCategory($origCategory);
         }
     }
     return $this->_productCollection;
 }
コード例 #4
0
ファイル: List.php プロジェクト: sandajith/mccconcierge
 /**
  * Retrieve loaded category collection
  *
  * @return Mage_Eav_Model_Entity_Collection_Abstract
  */
 protected function _getProductCollection()
 {
     if (is_null($this->_productCollection)) {
         $layer = $this->getLayer();
         /* @var $layer Mage_Catalog_Model_Layer */
         if ($this->getShowRootCategory()) {
             $this->setCategoryId(Mage::app()->getStore()->getRootCategoryId());
         }
         // if this is a product view page
         if (Mage::registry('product')) {
             // get collection of categories this product is associated with
             $categories = Mage::registry('product')->getCategoryCollection()->setPage(1, 1)->load();
             // if the product is associated with any category
             if ($categories->count()) {
                 // show products from this category
                 $this->setCategoryId(current($categories->getIterator()));
             }
         }
         $origCategory = null;
         if ($this->getCategoryId()) {
             $category = Mage::getModel('catalog/category')->load($this->getCategoryId());
             if ($category->getId()) {
                 $origCategory = $layer->getCurrentCategory();
                 $layer->setCurrentCategory($category);
                 $this->addModelTags($category);
             }
         }
         $this->_productCollection = $layer->getProductCollection();
         $current_cat = Mage::getSingleton('catalog/layer')->getCurrentCategory();
         $path = $current_cat->getPath();
         $ids = explode('/', $path);
         $topParent = 0;
         if (isset($ids[2])) {
             $topParent = $ids[2];
         }
         if ($topParent == '16') {
             $userid = Mage::getSingleton('customer/session')->getId();
             $user_id = $userid ? $userid : 0;
             $this->_productCollection->addAttributeToFilter('customer_id', $user_id);
         }
         $this->prepareSortableFieldsByCategory($layer->getCurrentCategory());
         if ($origCategory) {
             $layer->setCurrentCategory($origCategory);
         }
     }
     return $this->_productCollection;
 }
コード例 #5
0
ファイル: List.php プロジェクト: sixg/mkAnagh
 /**
  * Retrieve loaded category collection
  *
  * @return Mage_Eav_Model_Entity_Collection_Abstract
  */
 protected function _getVendorCollection()
 {
     if (is_null($this->_vendorCollection)) {
         $vendorIds = array();
         $model = Mage::getModel('csmarketplace/vshop')->getCollection()->addFieldToFilter('shop_disable', array('eq' => Ced_CsMarketplace_Model_Vshop::DISABLED));
         if (count($model) > 0) {
             foreach ($model as $row) {
                 $vendorIds[] = $row->getVendorId();
             }
         }
         $this->_vendorCollection = Mage::getModel('csmarketplace/vendor')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('status', array('eq' => Ced_CsMarketplace_Model_Vendor::VENDOR_APPROVED_STATUS));
         if (($countryId = $this->getRequest()->getParam('country_id')) && $this->getRequest()->getParam('country_id') != '') {
             $this->_vendorCollection->addAttributeToFilter('country_id', $countryId);
         }
         if (($postCode = $this->getRequest()->getParam('estimate_postcode')) && $this->getRequest()->getParam('estimate_postcode') != '') {
             $this->_vendorCollection->addAttributeToFilter('zip_code', $postCode);
         }
         if (($region = $this->getRequest()->getParam('region')) && $this->getRequest()->getParam('region') != '') {
             $this->_vendorCollection->addAttributeToFilter('region', $region);
         }
         if (($region_id = $this->getRequest()->getParam('region_id')) && $this->getRequest()->getParam('region_id') != '') {
             $this->_vendorCollection->addAttributeToFilter('region_id', $region_id);
         }
         $char = $this->getRequest()->getParam('char');
         if (strlen($char)) {
             $this->_vendorCollection->addAttributeToFilter('public_name', array('like' => '%' . $char . '%'));
         }
         if (count($vendorIds) > 0) {
             $this->_vendorCollection = $this->_vendorCollection->addAttributeToFilter('entity_id', array('nin' => $vendorIds));
         }
         if (!Mage::helper('csmarketplace')->isSharingEnabled()) {
             $this->_vendorCollection->addAttributeToFilter('website_id', array('eq' => Mage::app()->getStore()->getWebsiteId()));
         }
         $this->prepareSortableFields();
     }
     /*echo $this->_vendorCollection->getSelect();die;*/
     return $this->_vendorCollection;
 }
コード例 #6
0
 /**
  * Add store_id attribute to filter of EAV-collection
  *
  * @param Mage_Eav_Model_Entity_Collection_Abstract $collection
  */
 public function addStoreAttributeToFilter($collection)
 {
     $collection->addAttributeToFilter('store_id', array('in' => $this->_role->getStoreIds()));
 }
コード例 #7
0
ファイル: Visibility.php プロジェクト: arslbbt/mangentovies
 public function addVisibleInSearchFilterToCollection(Mage_Eav_Model_Entity_Collection_Abstract $collection)
 {
     $collection->addAttributeToFilter('visibility', array('in' => $this->getVisibleInSearchIds()));
     return $this;
 }
コード例 #8
0
ファイル: Status.php プロジェクト: arslbbt/mangentovies
 public function addSaleableFilterToCollection(Mage_Eav_Model_Entity_Collection_Abstract $collection)
 {
     $collection->addAttributeToFilter('status', array('in' => $this->getSaleableStatusIds()));
     return $this;
 }
コード例 #9
0
ファイル: Sale.php プロジェクト: santhosh400/ecart
 /**
  * Retrieve loaded category collection
  *
  * @return Mage_Eav_Model_Entity_Collection_Abstract
  */
 protected function _getProductCollections($page_id)
 {
     if (is_null($this->_productCollection)) {
         $layer = $this->getLayer();
         if ($this->getShowRootCategory()) {
             $this->setCategoryId(Mage::app()->getStore()->getRootCategoryId());
         }
         // if this is a product view page
         if (Mage::registry('product')) {
             // get collection of categories this product is associated with
             $categories = Mage::registry('product')->getCategoryCollection()->setPage(1, 1)->load();
             // if the product is associated with any category
             if ($categories->count()) {
                 // show products from this category
                 $this->setCategoryId(current($categories->getIterator()));
             }
         }
         $origCategory = null;
         if ($this->getCategoryId()) {
             $category = Mage::getModel('catalog/category')->load($this->getCategoryId());
             if ($category->getId()) {
                 $origCategory = $layer->getCurrentCategory();
                 $layer->setCurrentCategory($category);
                 $this->addModelTags($category);
             }
         }
         /* @var $layer Mage_Catalog_Model_Layer */
         /* @var $layer Mage_Catalog_Model_Layer */
         $this->_productCollection = $layer->getProductCollection();
         //Mage::getSingleton('core/session', array('name' => 'frontend'));
         $condition = new Zend_Db_Expr("special_price < price");
         $this->_productCollection = Mage::getResourceModel('catalogsearch/advanced_collection')->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addMinimalPrice()->addStoreFilter()->setPageSize(20)->addAttributeToFilter('upcomingproduct', 0);
         //->load();
         Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($this->_productCollection);
         Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($this->_productCollection);
         Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($this->_productCollection);
         $todayDate = date('m/d/y');
         $tomorrow = mktime(0, 0, 0, date('m'), date('d'), date('y'));
         $tomorrowDate = date('m/d/y', $tomorrow);
         $this->_productCollection->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))->addAttributeToFilter('special_to_date', array('or' => array(0 => array('date' => true, 'from' => $tomorrowDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left');
         $this->_productCollection->addAttributeToFilter('special_price', array('neq' => 'null'));
         //$this->_productCollection->addFieldToFilter('special_price', array('lt' => 'price'));
         if ($this->getRequest()->getParam('cat_id') != null) {
             //echo "hdjkdjdksjdks";
             $categoryId = $this->getRequest()->getParam('cat_id');
             $category = Mage::getModel('catalog/category')->load($categoryId);
             $this->_productCollection->addCategoryFilter($category);
         }
         $select = $this->_productCollection->getSelect();
         $currentUrl = $this->helper('core/url')->getCurrentUrl();
         $str = "sale";
         $str1 = "superdeals";
         if (strpos($currentUrl, $str) == true) {
             $select->where('price_index.final_price < price_index.price');
         } elseif (strpos($currentUrl, $str1) == true) {
             $select->where('price_index.final_price < price_index.price AND (100 - (price_index.final_price/price_index.price) * 100) > 20');
         } else {
             $select->where('price_index.final_price < price_index.price');
         }
         //exit;
         //print_r($collection);
         //$this->_productCollection = $layer->getProductCollections();
         //print_r($this->_productCollection);
     }
     return $this->_productCollection;
 }