本文整理汇总了PHP中Mage_Catalog_Block_Product_List类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Block_Product_List类的具体用法?PHP Mage_Catalog_Block_Product_List怎么用?PHP Mage_Catalog_Block_Product_List使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Catalog_Block_Product_List类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect
/**
* 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;
}
示例2: applyProductList
/**
* 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));
}
示例3: __construct
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);
}
示例4: _getProductCollection
/**
* 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;
}
示例5: _prepareLayout
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();
}
示例6: _toHtml
/**
* Get HTML if there's anything to show
*/
protected function _toHtml()
{
if ($this->_getProductCollection()->count()) {
return parent::_toHtml();
}
return '';
}
示例7: _construct
protected function _construct()
{
parent::_construct();
// set defaults
$this->setSortBy('relevance');
$this->setDefaultDirection('desc');
}
示例8: _getProductCollection
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;
}
示例9: testPrepareSortableFieldsByCategory
public function testPrepareSortableFieldsByCategory()
{
$category = new Mage_Catalog_Model_Category();
$category->setDefaultSortBy('name');
$this->_block->prepareSortableFieldsByCategory($category);
$this->assertEquals('name', $this->_block->getSortBy());
}
示例10: _preparePriceRenderer
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);
}
}
示例11:
function _toHtml()
{
if(!$this->_config['show']) return;
$this->__renderSlideShowImages();
$this->assign('configs', $this->_config);
$this->setTemplate($this->_config['template']);
return parent::_toHtml();
}
示例12: _prepareLayout
/**
* @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;
}
示例13: testPrepareSortableFieldsByCategory
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());
}
示例14: getPriceHtml
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;
}
示例15: _beforeToHtml
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();
}