Exemplo n.º 1
0
 /**
  * Collects list of objects in product list
  *
  * @param Mage_Catalog_Block_Product_List $object
  * @return Mage_Catalog_Model_Product[]
  */
 public function collect($object)
 {
     $result = array();
     $products = $object->getLoadedProductCollection();
     foreach ($products as $product) {
         $result[] = $product;
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Product list cache, needs to clear on displayed products
  *
  * @param Mage_Catalog_Block_Product_List $block
  */
 public function applyProductList(Mage_Catalog_Block_Product_List $block)
 {
     // The "messages" block is session-dependent, don't cache
     if (Mage::helper('cache')->responseHasMessages()) {
         $block->setData('cache_lifetime', null);
         return;
     }
     // Set cache tags
     $tags = array();
     $tags[] = Mage_Catalog_Model_Category::CACHE_TAG . '_' . $this->_getCategoryIdForProductList($block);
     // The toolbar needs to apply sort order etc
     $_toolbar = $block->getToolbarBlock();
     $productCollection = $block->getLoadedProductCollection();
     /**
      * @see Mage_Catalog_Block_Product_List_Toolbar::getCurrentOrder
      */
     if ($orders = $block->getAvailableOrders()) {
         $_toolbar->setAvailableOrders($orders);
     }
     if ($sort = $block->getSortBy()) {
         $_toolbar->setDefaultOrder($sort);
     }
     if ($dir = $block->getDefaultDirection()) {
         $_toolbar->setDefaultDirection($dir);
     }
     if ($modes = $block->getModes()) {
         $_toolbar->setModes($modes);
     }
     $_toolbar->setCollection($productCollection);
     $productIds = array();
     foreach ($productCollection as $_product) {
         $tags[] = Mage_Catalog_Model_Product::CACHE_TAG . "_" . $_product->getId();
         $productIds[] = $_product->getId();
     }
     if (!empty($productIds)) {
         $childIds = Mage::helper('cache')->getChildProductIds($productIds);
         foreach ($childIds as $childId) {
             $tags[] = Mage_Catalog_Model_Product::CACHE_TAG . '_' . $childId;
         }
     }
     $block->setData('cache_tags', $tags);
     // Set cache key
     $keys = $this->_getBasicKeys($block);
     $_taxRateRequest = Mage::getModel('tax/calculation')->getRateRequest();
     $_customer = Mage::getSingleton('customer/session')->getCustomer();
     $_categoryId = $this->_getCategoryIdForProductList($block);
     foreach (Mage::app()->getRequest()->getParams() as $key => $value) {
         $value = Mage::helper('cache')->paramValueToCacheKey($value);
         $keys[] = $key . '_' . $value;
     }
     $keys = array_merge($keys, array($_categoryId, $_toolbar->getCurrentOrder(), $_toolbar->getCurrentDirection(), $_toolbar->getCurrentMode(), $_toolbar->getCurrentPage(), $_toolbar->getLimit(), $_customer->getGroupId(), $_taxRateRequest->getCountryId(), $_taxRateRequest->getRegionId(), $_taxRateRequest->getPostcode(), $_taxRateRequest->getCustomerClassId(), Mage::registry('current_tag')));
     $block->setData('cache_key', $this->_getCacheKey($keys, $block));
 }
Exemplo n.º 3
0
 public function __construct($attributes = array())
 {
     parent::__construct($attributes);
     $selfData = $this->getData();
     // handler configuration for module config
     $configuration = $this->_getConfiguration();
     if (count($configuration)) {
         foreach ($configuration as $field => $value) {
             //if (!array_key_exists($field, $selfData)){
             $selfData[$field] = $value;
             //}
         }
     }
     //Zend_Debug::dump($attributes);die;
     // handler attributes for {{block ...}} in cms page
     if (count($attributes)) {
         foreach ($attributes as $field => $value) {
             //if (!array_key_exists($field, $selfData)){
             $selfData[$field] = $value;
             //}
         }
     }
     // re-save data
     $this->setData($selfData);
 }
Exemplo n.º 4
0
 /**
  * Retrieve loaded category collection
  *
  * @return Mage_Eav_Model_Entity_Collection_Abstract
  */
 protected function _getProductCollection()
 {
     if (is_null($this->_prodCollection)) {
         $collection = parent::_getProductCollection();
         /*Get customer "status" attribute options*/
         $_approvedStatusId = Mage::getStoreConfig('marketplace/status/approved');
         if ($_approvedStatusId) {
             $_customerData = Mage::getModel('customer/customer')->getCollection()->addFieldToFilter('status', $_approvedStatusId)->load();
             $where = 'ce.value IS NULL';
             $_sellerIds = array();
             /*Get array of seller ids with stats approved*/
             foreach ($_customerData as $_data) {
                 $_sellerIds[] = $_data['entity_id'];
             }
             if ($_sellerIds) {
                 $where .= " OR ce.value in (" . implode(',', $_sellerIds) . ")";
             }
             $resource = Mage::getSingleton('core/resource');
             $tableName = $resource->getTableName('catalog_product_entity_int');
             $collection->getSelect()->joinLeft($tableName . ' As ce', 'ce.entity_id=e.entity_id AND ce.attribute_id=' . Mage::helper('marketplace')->getProductSellerAttributeId(), null);
             $collection->getSelect()->where($where);
         }
         $this->_prodCollection = $collection;
     }
     return $this->_prodCollection;
 }
Exemplo n.º 5
0
 public function _prepareLayout()
 {
     parent::_prepareLayout();
     /*$pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
       //$pager->setAvailableLimit(array(5=>5,10=>10,20=>20,'all'=>'all'));
       $pager->setCollection($this->getCollection());
       $this->setChild('pager', $pager);
       $this->getCollection()->load();*/
     $name = 'gosf_cookie2013';
     if (Mage::getModel('core/cookie')->get($name) != 'gosf') {
         header('Location:http://www.zoffio.com/');
         exit;
     }
     $param = $this->getRequest()->getParam('id');
     if ($headBlock = $this->getLayout()->getBlock('head')) {
         if ($param == 20) {
             $headBlock->setTitle("Stationery");
             $headBlock->setDescription($gosfcategory['meta_descr']);
             $headBlock->setKeywords($gosfcategory['meta_tags']);
         }
         if ($param == 72) {
             $headBlock->setTitle("Tech & Digitals");
             $headBlock->setDescription($gosfcategory['meta_descr']);
             $headBlock->setKeywords($gosfcategory['meta_tags']);
         }
         if ($param == 126) {
             $headBlock->setTitle("Gift Items");
             $headBlock->setDescription($gosfcategory['meta_descr']);
             $headBlock->setKeywords($gosfcategory['meta_tags']);
         }
     }
     return $this;
     //return parent::_prepareLayout();
 }
Exemplo n.º 6
0
 /**
  * Get HTML if there's anything to show
  */
 protected function _toHtml()
 {
     if ($this->_getProductCollection()->count()) {
         return parent::_toHtml();
     }
     return '';
 }
Exemplo n.º 7
0
 protected function _construct()
 {
     parent::_construct();
     // set defaults
     $this->setSortBy('relevance');
     $this->setDefaultDirection('desc');
 }
Exemplo n.º 8
0
 public function _getProductCollection()
 {
     if ($this->getSkuList()) {
         $collection = Mage::getModel('catalog/product')->getCollection();
         $layer = $this->getLayer();
         $layer->prepareProductCollection($collection);
     } else {
         $collection = parent::_getProductCollection();
     }
     if ($this->getLimit()) {
         $collection->setPageSize($this->getLimit());
     }
     if ($this->getSortBy()) {
         $collection->setOrder($this->getSortBy(), $this->getSortByDirection());
     }
     if ($this->getSkuList()) {
         $select = $collection->getSelect();
         $separator = $this->getSeparator();
         if (empty($separator)) {
             $separator = ',';
         }
         $skus = explode($separator, $this->getSkuList());
         if (count($skus)) {
             $select->where('e.sku IN (?)', $skus);
             $escapedSkus = array();
             foreach ($skus as $sku) {
                 $escapedSkus[] = $collection->getConnection()->quote($sku);
             }
             $select->order(new Zend_Db_Expr('FIELD(e.sku, ' . join(',', $escapedSkus) . ')'));
         } else {
             $select->where('SKU IS NULL');
         }
     }
     return $collection;
 }
Exemplo n.º 9
0
 public function testPrepareSortableFieldsByCategory()
 {
     $category = new Mage_Catalog_Model_Category();
     $category->setDefaultSortBy('name');
     $this->_block->prepareSortableFieldsByCategory($category);
     $this->assertEquals('name', $this->_block->getSortBy());
 }
Exemplo n.º 10
0
 public function _preparePriceRenderer($productType)
 {
     if (Mage::getStoreConfig('settings/settings/enable') == 1) {
         return $this->_getPriceBlock($productType)->setTemplate('quickview/catalog/product/price.phtml')->setUseLinkForAsLowAs($this->_useLinkForAsLowAs);
     } else {
         return parent::_preparePriceRenderer($productType);
     }
 }
Exemplo n.º 11
0
	function _toHtml() 
	{			
		if(!$this->_config['show']) return;	
		$this->__renderSlideShowImages();
		$this->assign('configs', $this->_config);			
		$this->setTemplate($this->_config['template']);	
        return parent::_toHtml();	
	}
Exemplo n.º 12
0
 /**
  * @return $this
  */
 protected function _prepareLayout()
 {
     parent::_prepareLayout();
     $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
     $breadcrumbs->addCrumb('home', array('label' => Mage::helper('cms')->__('Home'), 'title' => Mage::helper('cms')->__('Home Page'), 'link' => Mage::getBaseUrl()));
     $breadcrumbs->addCrumb('brandname', array('label' => $this->_brandname, 'title' => $this->_brandname));
     return $this;
 }
Exemplo n.º 13
0
 public function testPrepareSortableFieldsByCategory()
 {
     /** @var $category Mage_Catalog_Model_Category */
     $category = Mage::getModel('Mage_Catalog_Model_Category');
     $category->setDefaultSortBy('name');
     $this->_block->prepareSortableFieldsByCategory($category);
     $this->assertEquals('name', $this->_block->getSortBy());
 }
Exemplo n.º 14
0
 public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix = '')
 {
     $html = parent::getPriceHtml($product, $displayMinimalPrice, $idSuffix);
     if (Mage::getStoreConfig('amconf/list/enable_list') == 1 && $product->isSaleable() && $product->isConfigurable()) {
         $html .= Mage::helper('amconf')->getHtmlBlock($product, '');
     }
     return $html;
 }
 protected function _beforeToHtml()
 {
     $collection = Mage::getSingleton('catalogsale/layer')->getProductCollection();
     $collection->setPageSize($this->getProductsCount())->setCurPage(1);
     $collection->getSelect()->order('rand()');
     $this->setProductCollection($collection);
     return parent::_beforeToHtml();
 }
Exemplo n.º 16
0
 public function getAddToCartUrl($product, $additional = array())
 {
     if (!isset($additional['_query'])) {
         $additional['_query'] = array();
     }
     $additional['_query']['flycart_item'] = $product->getId();
     return parent::getAddToCartUrl($product, $additional);
 }
Exemplo n.º 17
0
 public function __construct()
 {
     parent::__construct();
     $this->addPriceBlockType('bundle', 'bundle/catalog_product_price', 'bundle/catalog/product/price.phtml');
     $this->addPriceBlockType('giftcard', 'enterprise_giftcard/catalog_product_price', 'giftcard/catalog/product/price.phtml');
     $this->addPriceBlockType('msrp', 'catalog/product_price', 'catalog/product/price_msrp.phtml');
     $this->addPriceBlockType('msrp_item', 'catalog/product_price', 'catalog/product/price_msrp_item.phtml');
     $this->addPriceBlockType('msrp_noform', 'catalog/product_price', 'catalog/product/price_msrp_noform.phtml');
 }
Exemplo n.º 18
0
 protected function _prepareLayout()
 {
     $title = $this->getConfig("brandnav_title");
     if (!$title) {
         $title = $this->__("All Brands");
     }
     $this->getLayout()->getBlock('head')->setTitle($title);
     return parent::_prepareLayout();
 }
 public function __construct()
 {
     parent::__construct();
     if (Mage::helper('adjnav')->isModuleEnabled('Aitoc_Aitproductslists')) {
         $this->setTemplate('aitcommonfiles/design--frontend--base--default--template--catalog--product--list.phtml');
     } else {
         $this->setTemplate('catalog/product/list.phtml');
     }
 }
Exemplo n.º 20
0
 public function __construct()
 {
     parent::__construct();
     $now = date("Y-m-d 00:00:00");
     $collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToSelect('special_to_date')->addAttributeToFilter('status', 1)->addAttributeToFilter('visibility', array('neq' => 1))->addAttributeToFilter('special_price', array('neq' => ''))->addAttributeToFilter(array(array('attribute' => 'special_to_date', 'date' => true, 'gteq' => $now), array('attribute' => 'special_to_date', 'is' => new Zend_Db_Expr('null'))), '', 'left')->addAttributeToFilter(array(array('attribute' => 'special_from_date', 'date' => true, 'lteq' => $now), array('attribute' => 'special_from_date', 'is' => new Zend_Db_Expr('null'))), '', 'left');
     if ($limit = (int) Mage::getStoreConfig('onsale/configuration/limit')) {
         $collection->getSelect()->limit($limit);
     }
     $this->_collection = $collection;
 }
 protected function _beforeToHtml()
 {
     $blockName = $this->getToolbarBlockName();
     if (!$blockName) {
         $blockName = 'product_list_toolbar';
         $this->setToolbarBlockName($blockName);
         $this->getLayout()->createBlock($this->_defaultToolbarBlock, $blockName)->setTemplate('catalog/product/list/toolbar.phtml')->setChild($blockName . '_pager', $this->getLayout()->createBlock('page/html_pager', $blockName . '_pager'));
     }
     return parent::_beforeToHtml();
 }
Exemplo n.º 22
0
 protected function _beforeToHtml()
 {
     $collection = $this->_getProductCollection();
     $numProducts = $this->getNumProducts();
     if ($numProducts) {
         $collection->setPageSize($numProducts)->load();
     }
     $this->setCollection($collection);
     return parent::_beforeToHtml();
 }
Exemplo n.º 23
0
 protected function _getProductCollection()
 {
     parent::__construct();
     $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSort("entity_id", "DESC")->addAttributeToSelect(array('name', 'price', 'small_image'))->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInSiteIds())->setPageSize($this->get_prod_count())->addAttributeToSort($this->get_order(), $this->get_order_dir())->setCurPage($this->get_cur_page());
     Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
     Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
     Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($products);
     $this->_productCollection = $products;
     return $this->_productCollection;
 }
Exemplo n.º 24
0
 protected function _beforeToHtml()
 {
     $blockName = $this->getToolbarBlockName();
     if (!$blockName) {
         $blockName = 'product_list_toolbar';
         $this->setToolbarBlockName($blockName);
         $this->getLayout()->createBlock($this->_defaultToolbarBlock, $blockName, array('show_toolbar' => $this->getData('show_toolbar'), 'list_mode' => $this->getData('list_mode'), '_current_limit' => $this->getData('limit')))->setChild($blockName . '_pager', $this->getLayout()->createBlock('page/html_pager', $blockName . '_pager'));
     }
     return parent::_beforeToHtml();
 }
Exemplo n.º 25
0
 public function getAddToCartUrl($product, $additional = array())
 {
     $_modules = Mage::getConfig()->getNode('modules')->children();
     $_modulesArray = (array) $_modules;
     if (isset($_modulesArray['GoMage_Procart']) && $_modulesArray['GoMage_Procart']->is('active')) {
         if (Mage::helper('gomage_procart')->isProCartEnable() && Mage::getStoreConfig('gomage_procart/qty_settings/category_page')) {
             $additional['_query']['gpc_prod_id'] = $product->getId();
         }
     }
     return parent::getAddToCartUrl($product, $additional);
 }
Exemplo n.º 26
0
 protected function _getProductCollection()
 {
     parent::__construct();
     $storeId = Mage::app()->getStore()->getId();
     $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter(array(array('attribute' => 'featured', 'eq' => '1')))->setStoreId($storeId)->addStoreFilter($storeId)->setPageSize($this->get_prod_count())->addAttributeToSort($this->get_order(), $this->get_order_dir())->setCurPage($this->get_cur_page());
     Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
     Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
     Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($products);
     $this->_productCollection = $products;
     return $this->_productCollection;
 }
Exemplo n.º 27
0
 protected function _getProductCollection()
 {
     parent::__construct();
     $storeId = Mage::app()->getStore()->getId();
     $products = Mage::getResourceModel('reports/product_collection')->addOrderedQty()->addAttributeToSelect(array('name', 'price', 'small_image', 'short_description', 'description'))->setStoreId($storeId)->addStoreFilter($storeId)->setPageSize($this->get_prod_count())->setOrder($this->get_order(), $this->get_order_dir())->setCurPage($this->get_cur_page());
     Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
     Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
     Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($products);
     $this->_productCollection = $products;
     return $this->_productCollection;
 }
Exemplo n.º 28
0
 protected function _beforeToHtml()
 {
     parent::_beforeToHtml();
     if ($this->getMode() == 'grid') {
         $this->setTemplate('auction/grid.phtml');
     } else {
         $this->setTemplate('auction/list.phtml');
     }
     $this->setTemplate('auction/grid.phtml');
     return $this;
 }
Exemplo n.º 29
0
 public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix = '')
 {
     $html = parent::getPriceHtml($product, $displayMinimalPrice, $idSuffix);
     if ($this->isEnableShareFriend()) {
         // Add share friend for product list page
         $block = Mage::getBlockSingleton('affiliateplusreferfriend/product_refer');
         $block->setProduct($product);
         $html = $block->toHtml() . $html;
     }
     return $html;
 }
Exemplo n.º 30
-1
 public function getAddToCartUrl($product, $additional = array())
 {
     if ($this->helper('icart')->isEnabled()) {
         return $this->helper('icart')->getAddUrl($product, $additional);
     } else {
         return parent::getAddToCartUrl($product, $additional);
     }
 }