本文整理汇总了PHP中Mage_Catalog_Block_Product_List::setData方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Block_Product_List::setData方法的具体用法?PHP Mage_Catalog_Block_Product_List::setData怎么用?PHP Mage_Catalog_Block_Product_List::setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Block_Product_List
的用法示例。
在下文中一共展示了Mage_Catalog_Block_Product_List::setData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例2: testGetPriceBlockTemplate
public function testGetPriceBlockTemplate()
{
$this->assertNull($this->_block->getPriceBlockTemplate());
$this->_block->setData('price_block_template', 'test');
$this->assertEquals('test', $this->_block->getPriceBlockTemplate());
}