本文整理汇总了PHP中Mage_Catalog_Block_Product_Abstract::_beforeToHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Block_Product_Abstract::_beforeToHtml方法的具体用法?PHP Mage_Catalog_Block_Product_Abstract::_beforeToHtml怎么用?PHP Mage_Catalog_Block_Product_Abstract::_beforeToHtml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Block_Product_Abstract
的用法示例。
在下文中一共展示了Mage_Catalog_Block_Product_Abstract::_beforeToHtml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeToHtml
protected function _beforeToHtml()
{
$todayDate = AO::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$collection = $this->_addProductAttributesAndPrices(AO::getResourceModel('catalog/product_collection'))->addStoreFilter()->addAttributeToFilter('news_from_date', array('date' => true, 'to' => $todayDate))->addAttributeToFilter('news_to_date', array('or' => array(0 => array('date' => true, 'from' => $todayDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')->addAttributeToSort('news_from_date', 'desc')->setPageSize($this->getProductsCount())->setCurPage(1);
$this->setProductCollection($collection);
return parent::_beforeToHtml();
}
示例2: _beforeToHtml
protected function _beforeToHtml()
{
if ($this->getTemplate() == 'dgt/widget/default.phtml') {
switch ($this->getData('widget_type')) {
case 'product':
switch ($this->getData('mode')) {
case 'related':
$this->setTemplate('dgt/widget/related.phtml');
break;
default:
$this->setTemplate('dgt/widget/product.phtml');
break;
}
switch ($this->getData('widget_tab')) {
case 'categories':
case 'collections':
$this->setTemplate('dgt/widget/tab.phtml');
break;
}
break;
case 'attribute':
$this->setTemplate('dgt/widget/attribute.phtml');
break;
case 'block':
$this->setTemplate('dgt/widget/block.phtml');
break;
case 'category':
$this->setTemplate('dgt/widget/category.phtml');
break;
}
}
return parent::_beforeToHtml();
}
示例3: _beforeToHtml
protected function _beforeToHtml()
{
$toolbar = $this->getToolbarBlock();
// called prepare sortable parameters
$collection = $this->getProductCollectionGroup();
// use sortable parameters
if ($orders = $this->getAvailableOrders()) {
$toolbar->setAvailableOrders($orders);
}
if ($sort = $this->getSortBy()) {
$toolbar->setDefaultOrder($sort);
}
if ($dir = $this->getDefaultDirection()) {
$toolbar->setDefaultDirection($dir);
}
if ($modes = $this->getModes()) {
$toolbar->setModes($modes);
}
// set collection to toolbar and apply sort
$toolbar->setCollection($collection);
$this->setChild('toolbar', $toolbar);
Mage::dispatchEvent('catalog_block_product_list_collection', array('collection' => $this->getProductCollectionGroup()));
$this->getProductCollectionGroup()->load();
return parent::_beforeToHtml();
}
示例4: _beforeToHtml
protected function _beforeToHtml()
{
if (!$this->_configs['show']) {
return;
}
//Handle data from call line in xml (custom design)
foreach ($this->_configs as $key => $value) {
$data = $this->getData($key);
if ($data) {
$this->_configs[$key] = $data;
}
}
$detect = Mage::helper('joomlart_jmslideshow/mobiledetect');
if ($detect->isTablet()) {
if ($this->_configs["mainWidthtablet"]) {
$this->_configs["mainWidth"] = $this->_configs["mainWidthtablet"];
}
} else {
if ($detect->isMobile()) {
if ($this->_configs["mainWidthmobile"]) {
$this->_configs["mainWidth"] = $this->_configs["mainWidthmobile"];
}
}
}
return parent::_beforeToHtml();
}
示例5: _beforeToHtml
protected function _beforeToHtml()
{
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$collection = $this->_addProductAttributesAndPrices($collection)->addStoreFilter()->addAttributeToSort('entity_id', 'desc')->setPageSize($this->getLimit())->setCurPage(1);
$this->setProductCollection($collection);
return parent::_beforeToHtml();
}
示例6: _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();
}
示例7: _beforeToHtml
/**
* Need use as _prepareLayout - but problem in declaring collection from
* another block (was problem with search result)
*/
protected function _beforeToHtml()
{
foreach ($this->_config as $key => $value) {
if ($this->getData($key)) {
$this->_config[$key] = $this->getData($key);
}
}
return parent::_beforeToHtml();
}
示例8: _beforeToHtml
/**
* Prepare collection with new products and applied page limits.
*
* return Mage_Catalog_Block_Product_New
*/
protected function _beforeToHtml()
{
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$collection = $this->_addProductAttributesAndPrices($collection)->addStoreFilter()->addAttributeToFilter('special_from_date', array('or' => array(0 => array('date' => true, 'to' => $todayDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')->addAttributeToFilter('special_to_date', array('or' => array(0 => array('date' => true, 'from' => $todayDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')->addAttributeToFilter(array(array('attribute' => 'special_from_date', 'is' => new Zend_Db_Expr('not null')), array('attribute' => 'special_to_date', 'is' => new Zend_Db_Expr('not null'))))->addAttributeToSort('special_from_date', 'asc')->setPageSize($this->getProductsCount())->setCurPage(1);
$this->setProductCollection($collection);
return parent::_beforeToHtml();
}
示例9: _beforeToHtml
protected function _beforeToHtml()
{
$storeId = Mage::app()->getStore()->getId();
$products = Mage::getResourceModel('reports/product_collection')->addOrderedQty()->addAttributeToSelect('*')->addAttributeToSelect(array('name', 'price', 'small_image'))->setStoreId($storeId)->addStoreFilter($storeId)->addViewsCount();
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
$products->setPageSize($this->getModel()->getPopularCount())->setCurPage(1);
$this->setProductCollection($products);
return parent::_beforeToHtml();
}
示例10: _beforeToHtml
protected function _beforeToHtml()
{
$collection = Mage::getResourceModel('catalog/product_collection');
$attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
$collection->addAttributeToSelect($attributes)->addMinimalPrice()->addFinalPrice()->addTaxPercents()->addAttributeToFilter('inchoo_featured_product', 1, 'left')->addStoreFilter()->getSelect()->order($this->getSortBy())->limit($this->getLimit());
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
$this->_productCollection = $collection;
$this->setProductCollection($collection);
return parent::_beforeToHtml();
}
示例11: _beforeToHtml
/**
* Prepare collection with new products and applied page limits.
*
* return Mage_Catalog_Block_Product_New
*/
protected function _beforeToHtml()
{
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$collection = $this->_addProductAttributesAndPrices($collection)->addStoreFilter();
$collection->addAttributeToSelect('feature_product');
$collection->addFieldToFilter(array(array('attribute' => 'feature_product', 'eq' => true)));
$collection->addAttributeToSort('news_from_date', 'asc')->setPageSize($this->getProductsCount())->setCurPage(1);
$this->setProductCollection($collection);
return parent::_beforeToHtml();
}
示例12: _beforeToHtml
protected function _beforeToHtml()
{
$storeId = Mage::app()->getStore()->getId();
$sellDate = $this->getModel()->getSellDate($this->getModel()->getHomepageDaysLimit());
$collection = Mage::getResourceModel('reports/product_sold_collection')->addOrderedQty()->setStoreId($storeId)->addStoreFilter($storeId)->setDateRange($sellDate['startdate'], $sellDate['todaydate'])->addUrlRewrite()->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->setOrder('ordered_qty', 'desc')->setPageSize($this->getModel()->getTopsellCount())->setCurPage(1)->setOrder('ordered_qty', 'desc');
$catId = Mage::getStoreConfig('homepage/topsell/homecat');
if ($catId > 0) {
$category = $this->getModel()->getCategory($catId);
$collection->addCategoryFilter($category);
}
$this->setProductCollection($collection);
return parent::_beforeToHtml();
}
示例13: _beforeToHtml
protected function _beforeToHtml()
{
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$collection = Mage::getResourceModel('catalog/product_collection');
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
$collection = $this->_addProductAttributesAndPrices($collection)->addStoreFilter()->addAttributeToFilter('news_from_date', array('date' => true, 'to' => $todayDate))->addAttributeToFilter('news_to_date', array('or' => array(0 => array('date' => true, 'from' => $todayDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')->addAttributeToSort('news_from_date', 'desc')->setPageSize($this->getProductsCount())->setCurPage(1);
if ($categoryId = $this->getRequest()->getParam('id')) {
$category = Mage::getModel('catalog/category')->load($categoryId);
$collection->addCategoryFilter($category);
}
$this->setProductCollection($collection);
return parent::_beforeToHtml();
}
示例14: _beforeToHtml
/**
* Prepare collection with new products and applied page limits.
*
* return Mage_Catalog_Block_Product_New
*/
protected function _beforeToHtml()
{
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$collection = $this->_addProductAttributesAndPrices($collection)->addStoreFilter()->addAttributeToFilter('special_from_date', array('or' => array(0 => array('date' => true, 'to' => $todayDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')->addAttributeToFilter('special_to_date', array('or' => array(0 => array('date' => true, 'from' => $todayDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')->addAttributeToFilter(array(array('attribute' => 'special_from_date', 'is' => new Zend_Db_Expr('not null')), array('attribute' => 'special_to_date', 'is' => new Zend_Db_Expr('not null'))))->addAttributeToSort('special_from_date', 'asc')->setPageSize(8)->setCurPage(1);
// Limit to a specific category
$_cat_id = (int) Mage::getStoreConfig('milanoconfig/homeoptions/sale_products_cat_id');
if ($_cat_id) {
$collection->addCategoryFilter(Mage::getModel("catalog/category")->load($_cat_id));
}
$this->setProductCollection($collection);
return parent::_beforeToHtml();
}
示例15: _beforeToHtml
protected function _beforeToHtml()
{
$storeId = Mage::app()->getStore()->getId();
$collection = Mage::getResourceModel('reports/product_collection')->addAttributeToSelect('*')->setStoreId($storeId)->addStoreFilter($storeId)->addViewsCount()->setPageSize($this->getModel()->getCatProductsLimit())->setCurPage(1)->setOrder('views_count', 'desc');
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
$c = Mage::registry("current_category");
$catId = $c->getData('entity_id');
if ($catId > 0) {
$category = $this->getModel()->getCategory($catId);
$collection->addCategoryFilter($category);
}
$this->setProductCollection($collection);
return parent::_beforeToHtml();
}