========= ===========

我接受 Simonthesorcerer 回应,但是 对我不起作用.

我找到了一个免费的模块,您可以在此URL上获得: http://www.magentocommerce.com/magento-connect/thirty4+ interactive/extensive/841/catalog-sale-items

它可以很好地工作 CE 1.7.0.2 如果您从这里手动安装它: http://freegento.com/magento-extensions/thirty4_catalogsale-0.6.3_ready2paste.tgz

下载,解压缩并将文件夹中的文件移至Magento安装中。

希望这对某人有用!

========

我正在尝试制作一个特殊的价格页面...尝试和重试后,几次失败后,我想到了:

我创建了一个名为: Special.php 进入这条路: app/code/local/Mage/Catalog/Block/Product/ 使用此代码:

<?php
class Mage_Catalog_Block_Product_Special extends Mage_Catalog_Block_Product_List {
   function get_prod_count() {

      Mage::getSingleton('catalog/session')->unsLimitPage();
      return (isset($_REQUEST['limit'])) ? intval($_REQUEST['limit']) : 300;
   }

   function get_cur_page() {
      return (isset($_REQUEST['p'])) ? intval($_REQUEST['p']) : 1;
   }

   protected function _getProductCollection() {
        $todayDate  = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
        $tomorrow = mktime(0, 0, 0, date('m'), date('d')+1, date('y'));
        $dateTomorrow = date('m/d/y', $tomorrow);

        $collection = Mage::getResourceModel('catalog/product_collection');
        $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());

        $collection = $this->_addProductAttributesAndPrices($collection)
        ->addStoreFilter()
        ->addAttributeToSort('entity_id', 'desc')
        ->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate)) 
        ->addAttributeToFilter('special_to_date', array('or'=> array(0 => array('date' => true, 'from' => $dateTomorrow), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')
        ->setPageSize($this->get_prod_count())
        ->setCurPage($this->get_cur_page());

        $this->setProductCollection($collection);
        return $collection;
   }
}
?>

在那之后

我创建了一个名为: Special.phtml 进入这条路: app/design/frontend/default/MY THEME NAME/template/catalog/product/ 使用此代码:

<?php 
    $columnsCount = 3;
    if (($_products = $this->getProductCollection()) && $_products->getSize()): 
?>

<div class="category-products">
<ol class="products-grid"  style="list-style: none;">
    <?php $i = 0; foreach ($_products->getItems() as $_product): ?>
    <?php // if($i++%$columnsCount == 0) : ?><?php // endif; ?>
     <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
            <?php // Product Image ?>
            <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
                <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(300, 200); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
            </a>

            <div class="product-shop">
                <div class="f-fix">
                    <?php // Product Title ?>
                    <h2 class="the-product-manufacturer-grid"><a href=""><?php echo $_product->getAttributeText('manufacturer') ?></a><span class="the-product-name-grid"> / <a class="product-name" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>)"><?php echo $this->htmlEscape($_product->getName()) ?></a></span></h2>

                    <?php // Product Price ?>
                    <div class="listpricebox"><?php echo $this->getPriceHtml($_product, true, $this->getPriceSuffix()) ?></div>
                </div>
            </div>
    </li>
    <?php // if($i%$columnsCount == 0 || $i == count($_products)): ?><?php // endif; ?>
    <?php endforeach; ?>
</ol>
</div>

<script type="text/javascript">decorateGeneric($$('.grid-row'), ['first', 'last', 'odd', 'even']);</script>
<?php endif; ?>

最后,我将所有这些东西称为CMS页面

{{block type="catalog/product_special" template="catalog/product/special.phtml"}}

现在,一切正常,除了此页面仅通过编辑产品以一对一设置的特殊价格显示产品的事实。但是我产品的最大部分是通过 目录价格规则 有人有一个主意吗 目录价格规则 产品和 “特价” 产品?

====== update =======

这是代码

<?php
class Mage_Catalog_Block_Product_Special extends Mage_Catalog_Block_Product_List {

   protected function _getProductCollection() {
        // we need the date to filter for the special price
    $dateToday = date('m/d/y'); 
    $tomorrow = mktime(0, 0, 0, date('m'), date('d')+1, date('y'));
    $dateTomorrow = date('m/d/y', $tomorrow);

// this gets the product collection and filters for special price;
// grabs products with special_from_date at least today, and special_to_date at least tomorrow
        $_productCollection = Mage::getModel('catalog/product')->getCollection()
            ->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $dateToday))
            ->addAttributeToFilter('special_to_date', array('date' => true, 'from' => $dateTomorrow))
            ->load();

// this loads the standard magento catalog proce rule model
        $rules = Mage::getResourceModel('catalogrule/rule_collection')->load();

// read: if there are active rules
        if($rules->getData()) {
            $rule_ids = array(); // i used this down below to style the products according to which rule affected
            $productIds[] = array(); // this will hold the ids of the products

            foreach($rules as $rule) {
                $rule_ids[] = $rule->getId();
                $productIds = $rule->getMatchingProductIds(); // affected products come in here
            }

// merge the collections: $arr is an array and keeps all product IDs we fetched before with the special-price-stuff
            $arr = $_productCollection->getAllIds();
            if($productIds) {
                // if there are products affected by catalog price rules, $arr now also keeps their IDs
                $arr = array_merge($arr,$productIds);
            }

// we initialize a new collection and filter solely by the product IDs we got before, read: select all products with their entity_id in $arr
            $_productCollection = Mage::getModel('catalog/product')->getCollection()
                ->addAttributeToFilter('entity_id',array('in'=>$arr))
                ->load();
        }
   }
}
有帮助吗?

解决方案

我花了一段时间才弄清楚这一点。如果您为您的需求定制它,应该为您工作。

要列出受价格规则影响的产品,您必须越过规则模型。

这是代码:

<?php
// we need the date to filter for the special price
    $dateToday = date('m/d/y'); 
    $tomorrow = mktime(0, 0, 0, date('m'), date('d')+1, date('y'));
    $dateTomorrow = date('m/d/y', $tomorrow);

// this gets the product collection and filters for special price;
// grabs products with special_from_date at least today, and special_to_date at least tomorrow
        $_productCollection = Mage::getModel('catalog/product')->getCollection()
            ->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $dateToday))
            ->addAttributeToFilter('special_to_date', array('date' => true, 'from' => $dateTomorrow))
            ->load();

// this loads the standard magento catalog proce rule model
        $rules = Mage::getResourceModel('catalogrule/rule_collection')->load();

// read: if there are active rules
        if($rules->getData()) {
            $rule_ids = array(); // i used this down below to style the products according to which rule affected
            $productIds[] = array(); // this will hold the ids of the products

            foreach($rules as $rule) {
                $rule_ids[] = $rule->getId();
                $productIds = $rule->getMatchingProductIds(); // affected products come in here
            }

// merge the collections: $arr is an array and keeps all product IDs we fetched before with the special-price-stuff
            $arr = $_productCollection->getAllIds();
            if($productIds) {
                // if there are products affected by catalog price rules, $arr now also keeps their IDs
                $arr = array_merge($arr,$productIds);
            }

// we initialize a new collection and filter solely by the product IDs we got before, read: select all products with their entity_id in $arr
            $_productCollection = Mage::getModel('catalog/product')->getCollection()
                ->addAttributeToFilter('entity_id',array('in'=>$arr))
                ->load();
        }

==更新==

我在代码中添加了一些评论,并重命名 $skus$productIds (更合适)。

如果您仍然遇到错误,请让我知道到底发生了什么。该代码对Magento V1.7.0.2进行了测试。

干杯
西蒙

其他提示

这是对我有用的代码。

  1. 首先创建模板文件,例如您的sales-pecial.phtml app/design/frontend/jewelry/default/template/catalog/product 文件夹

销售概况的内容是

  $_productCollection = Mage::getModel('catalog/product')->getCollection();
$_productCollection->addAttributeToSelect(array(
   'image',
   'name',
   'short_description'
))
->addFieldToFilter('visibility', array(
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
)) 
->addFinalPrice()
//                        ->addAttributeToSort('price', 'asc') 
->getSelect()
->where('price_index.final_price < price_index.price');
Mage::getModel('review/review')->appendSummary($_productCollection);

$_helper = $this->helper('catalog/output');
$_collectionSize = $_productCollection->count();

if(!$_collectionSize): ?>
<div class="category-products"><p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p></div>
<?php else: ?>
<div class="category-products">
<div class="toolbar-top"><?php echo $this->getToolbarHtml() ?></div>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php 
$_iterator = 0;
// List Mode            
$_wImgList = 190;
$_hImgList = 190;
if(Mage::helper('themeframework/settings')->getProductsList_ImageRatio()!=0){
$_ratioImgList = Mage::helper('themeframework/settings')->getProductsList_ImageRatio();
if($_ratioImgList!='-1'){
$_hImgList = $_wImgList/$_ratioImgList;    
}else{
$_hImgList = ($_wImgList * Mage::helper('themeframework/settings')->getProductsList_CustomHeight())/Mage::helper('themeframework/settings')->getProductsList_CustomWidth();
}                        
} 

$altImgList = Mage::helper('themeframework/settings')->getProductsList_AltImg();
$gutterList = Mage::helper('themeframework/settings')->getProductsList_Gutter(); 
?>
<ol class="products-list" id="products-list">
<?php foreach ($_productCollection as $_product): ?>
<li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>" <?php if($gutterList): ?>style="margin-bottom: <?php echo $gutterList; ?>px"<?php endif; ?>>

<?php if (Mage::helper('themeframework/settings')->getProductsList_ShowThumbnail()): ?>

<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
<?php if (Mage::helper('themeframework/settings')->getProductsList_ShowLabel()):?>
<!--show label product - label extension is required-->
<?php Mage::helper('productlabels')->display($_product);?>
<?php endif ?>
<?php if($altImgList):?>
<img class="em-img-lazy img-responsive em-alt-hover" src="<?php echo $this->getSkinUrl('images/loading.gif') ?>" data-original="<?php echo $this->helper('catalog/image')->init($_product, $altImgList)->resize($_wImgList, $_hImgList); ?>" width="<?php echo $_wImgList ?>" height="<?php echo $_hImgList ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, $altImgList), null, true) ?>" />
<?php endif;?>
<img id="product-collection-image-<?php echo $_product->getId(); ?>" class="em-img-lazy img-responsive <?php if ($altImgList): ?>em-alt-org<?php endif ?>" src="<?php echo $this->getSkinUrl('images/loading.gif') ?>" data-original="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_wImgList, $_hImgList); ?>" width="<?php echo $_wImgList ?>" height="<?php echo $_hImgList ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
</a>
<?php else:?>
<?php if (Mage::helper('themeframework/settings')->getProductsList_ShowLabel()):?>
<!--show label product - label extension is required-->
<?php Mage::helper('productlabels')->display($_product);?></a>
<?php endif ?>            
<?php endif 
// Product description ?>
<div class="product-shop">
<div class="f-fix">
<?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
<!--product name-->
<?php if (Mage::helper('themeframework/settings')->getProductsList_ShowProductName()):?>
<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>">
<?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?>
</a></h2>
<?php
    if ($this->getChild('name.after')) {
        $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren();
        foreach ($_nameAfterChildren as $_nameAfterChildName) {
            $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName);
            $_nameAfterChild->setProduct($_product);
            echo $_nameAfterChild->toHtml();
        }
    } endif ?>  

<!--product description-->
<?php if (Mage::helper('themeframework/settings')->getProductsList_ShowDesc()): ?>
<div class="desc std">
<?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
</div> 
<?php endif ?> 
<!--show reviews-->
<?php if (Mage::helper('themeframework/settings')->getProductsList_ShowReviews()):?>
<?php if($_product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php endif; ?>
<?php endif
if (Mage::helper('themeframework/settings')->getProductsList_ShowPrice()): ?>
<?php echo $this->getPriceHtml($_product, true) ?>
<?php endif ?>

<div class="actions">
<?php if($_product->isSaleable()): ?>
<?php if (Mage::helper('themeframework/settings')->getProductsList_ShowAddtocart()): ?>
<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<?php endif ?>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<?php if (Mage::helper('themeframework/settings')->getProductsList_ShowAddto()): ?> 
<ul class="add-to-links">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
    <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist" title="<?php echo $this->__('Add to Wishlist') ?>"><?php echo $this->__('Add to Wishlist') ?></a></li>
<?php endif; ?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
    <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare" title="<?php echo $this->__('Add to Compare') ?>"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>
</ul>
<?php endif ?>
</div>
</div>
</div>
</li>
<?php endforeach; ?>
</ol>
<script type="text/javascript">decorateList('products-list', 'none-recursive')</script>

<?php else: ?>

<?php // Grid Mode ?>
<?php
// set column count    
$_pageLayout = substr((str_replace(array('page/','.phtml'),'',Mage::app()->getLayout()->getBlock('root')->getTemplate())),0,1);            

// Grid Mode            
$_wImgGrid = 280;
$_hImgGrid = 280;       
if(Mage::helper('themeframework/settings')->getProductsGrid_ImageRatio()!=0){
$_ratioImgGrid = Mage::helper('themeframework/settings')->getProductsGrid_ImageRatio();
if(Mage::helper('themeframework/settings')->getGeneral_DisableResponsive(1)!=0){
switch(Mage::helper('themeframework/settings')->checkDevice()){
case 'desktop':
switch($_pageLayout){
case 3:
    $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_Threecolumns(3);                    
    break;
case 1:
    $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_Onecolumn(5);
    break;
default:
    $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_Twocolumns(4); 
    break;
}
$_winWidth = 1200;
break;
case 'tablet':
switch($_pageLayout){
case 3:
    $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_TabletThreecolumns(3);                    
    break;
case 1:
    $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_TabletOnecolumn(5);
    break;
default:
    $_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_TabletTwocolumns(4); 
    break;
}
$_winWidth = 1024;
break;
case 'mobile': 
$_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_ItemsMobile(3);
$_winWidth = 320;
break;
}
}else{
switch($_pageLayout){
case 3:
$_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_Threecolumns(3);                    
break;
case 1:
$_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_Onecolumn(5);
break;
default:
$_columnCount = Mage::helper('themeframework/settings')->getProductsGrid_Twocolumns(4); 
break;
}
$_winWidth = 1200;                
} 
switch($_pageLayout){
case 3:
$_columnsContent = 12;                    
break;
case 1:
$_columnsContent = 24;
break;
default:
$_columnsContent = 18; 
break;
}
$_wImgGrid = (($_columnsContent/24) * $_winWidth)/$_columnCount - 20;
if($_ratioImgGrid==-1){
$_hImgGrid = ($_wImgGrid*Mage::helper('themeframework/settings')->getProductsGrid_CustomHeight())/Mage::helper('themeframework/settings')->getProductsGrid_CustomWidth();
}else{
$_hImgGrid = ($_wImgGrid/$_ratioImgGrid);
}
}   

$altImgGrid = Mage::helper('themeframework/settings')->getProductsGrid_AltImg();    

// Hover Effect
switch(Mage::helper('themeframework/settings')->getProductsGrid_ConfigHover()){
case 'enable':
$_classHoverEffect = 'emcatalog-enable-hover';
break;
case 'medium_desktop':
$_classHoverEffect = 'emcatalog-disable-hover-below-desktop';
break;
case 'tablet':
$_classHoverEffect = 'emcatalog-disable-hover-below-tablet';
break;
case 'mobile':
$_classHoverEffect = 'emcatalog-disable-hover-below-mobile';
break;
default:
$_classHoverEffect= '';
break; 
}

// Element Align Center
switch(Mage::helper('themeframework/settings')->getProductsGrid_AlignCenter()){
case 0:
$_classAlignCenter = '';
break;
default:
$_classAlignCenter= 'text-center';
break; 
}

// Product Name Single Line
switch(Mage::helper('themeframework/settings')->getProductsGrid_AutoProductName()){
case 0:
$_classNameSingleLine = '';
break;
default:
$_classNameSingleLine= 'em-productname-single-line';
break; 
}
?>
<?php if ($_collectionSize > 0): ?>
<div id="em-grid-mode">       
<ul class="emcatalog-grid-mode products-grid  <?php echo $_classHoverEffect ?>">
<?php $i=0; foreach ($_productCollection as $_product): ?>   
<li class="item<?php echo $i == 0 ?' first':''; ?><?php echo $i+1 == $_collectionSize ?' last':''; ?>">
<div class="product-item">                        
<div class="product-shop-top">
<!-- Show Thumbnail -->
<?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowThumbnail()): ?>
    <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
        <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowLabel()):?>
            <!--show label product - label extension is required-->
            <?php Mage::helper('productlabels')->display($_product);?>
        <?php endif;?>

        <?php if($altImgGrid):?>
            <img class="em-img-lazy img-responsive em-alt-hover" src="<?php echo $this->getSkinUrl('images/loading.gif') ?>" data-original="<?php echo $this->helper('catalog/image')->init($_product, $altImgGrid)->resize($_wImgGrid, $_hImgGrid); ?>" width="<?php echo $_wImgGrid ?>" height="<?php echo $_hImgGrid ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, $altImgGrid), null, true) ?>" />
        <?php endif;?>
        <img id="product-collection-image-<?php echo $_product->getId(); ?>" class="em-img-lazy img-responsive <?php if ($altImgGrid): ?>em-alt-org<?php endif ?>" src="<?php echo $this->getSkinUrl('images/loading.gif') ?>" data-original="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_wImgGrid, $_hImgGrid); ?>" width="<?php echo $_wImgGrid ?>" height="<?php echo $_hImgGrid ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /><span class="bkg-hover"></span>                                                    
    </a>
<?php else:?>
    <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowLabel()):?>
        <!--show label product - label extension is required-->
        <?php Mage::helper('productlabels')->display($_product);?>
    <?php endif;?>
<?php endif; ?>

<div class="bottom">
    <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowAddtocart()): ?>
    <div class="em-btn-addto <?php echo $_classAlignCenter ?> <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowAddtocart()==2): ?>em-element-display-hover<?php endif;?>">
        <?php if($_product->isSaleable()): ?>
            <!--show button add to cart-->                                            
            <button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>                                            
        <?php else: ?>
            <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
        <?php endif; ?>

        <!--show button add to compare-wishlist-->                                         
        <ul class="add-to-links">
            <?php if ($this->helper('wishlist')->isAllow()) : ?>
                <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist" title="<?php echo $this->__('Add to Wishlist') ?>"><?php echo $this->__('Add to Wishlist') ?></a></li>
            <?php endif; ?>
            <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                <li><a href="<?php echo $_compareUrl ?>" class="link-compare" title="<?php echo $this->__('Add to Compare') ?>"><?php echo $this->__('Add to Compare') ?></a></li>
            <?php endif; ?>
        </ul>
    </div>
    <?php endif;?>
    <?php if(Mage::helper('core')->isModuleEnabled('EM_Quickshop') && Mage::helper('quickshop')->getConfig('enable')): ?>
    <div class="quickshop-link-container hidden-xs">
        <a href="<?php echo Mage::helper('quickshop/links')->addQuickShopLink($_product->getProductUrl()); ?>" class="quickshop-link" title="<?php echo $this->__('Quickshop') ?>"><?php echo $this->__('Quickshop') ?></a>
    </div> 
    <?php endif;?>
</div> 
</div>

<div class="product-shop">
<div class="f-fix">
    <!--product name-->
    <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowProductName()):?>                    
    <h2 class="product-name <?php echo $_classAlignCenter ?> <?php echo $_classNameSingleLine ?> <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowProductName() == 2):?>em-element-display-hover<?php endif;?>"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>">
        <?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?>
    </a></h2>
    <?php
            // Provides extra blocks on which to hang some features for products in the list
            // Features providing UI elements targeting this block will display directly below the product name
            if ($this->getChild('name.after')) {
                $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren();
                foreach ($_nameAfterChildren as $_nameAfterChildName) {
                    $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName);
                    $_nameAfterChild->setProduct($_product);
                    echo $_nameAfterChild->toHtml();
                }
            }
    ?>
    <?php endif; ?>

    <!--show reviews-->
    <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowReviews()):?>
        <div class="<?php if(Mage::helper('themeframework/settings')->getProductsGrid_ShowReviews() == 2):?>em-element-display-hover<?php endif;?> <?php echo $_classAlignCenter ?>"><?php echo $this->getReviewsSummaryHtml($_product, 'short') ?></div>                                        
    <?php endif; ?>

    <!--product price-->
    <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowPrice()): ?>
        <div class="<?php echo $_classAlignCenter ?> <?php if(Mage::helper('themeframework/settings')->getProductsGrid_ShowPrice() == 2): ?>em-element-display-hover<?php endif;?>"><?php echo $this->getPriceHtml($_product, true) ?></div>
    <?php endif; ?>

    <!--product description-->
    <?php if (Mage::helper('themeframework/settings')->getProductsGrid_ShowDesc()): ?>
    <div class="desc std <?php echo $_classAlignCenter ?> <?php if(Mage::helper('themeframework/settings')->getProductsGrid_ShowDesc() == 2):?>em-element-display-hover<?php endif;?>">
        <?php 
            $shortdes =  $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description');
            if(strlen($shortdes)>100) { //dem ki tu chuoi $str, 80 la chieu dai muon quy dinh
                $strCutTitle = substr($shortdes, 0, 57); //cat 80 ki tu dau
                $shortdes = substr($strCutTitle, 0, strrpos($strCutTitle, ' '));
                $shortdes = substr_replace($shortdes ,"...",-3);
            }
            echo $this->stripTags($shortdes,null,true);
        ?>
    </div>
    <?php endif; ?>                                                         
</div>
</div>
</div> 
</li>   
<?php $i++;?>
<?php if($i >= $_collectionSize) break;?>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<?php 
if(Mage::helper('themeframework/settings')->getGeneral_DisableResponsive(1)!=0){
switch($_pageLayout){
case 3:
$_columnCountDesktop = Mage::helper('themeframework/settings')->getProductsGrid_Threecolumns(3);
$_columnCountDesktopSmall = Mage::helper('themeframework/settings')->getProductsGrid_DesktopSmallThreecolumns(3);
$_columnCountTablet = Mage::helper('themeframework/settings')->getProductsGrid_TabletThreecolumns(3);                    
break;
case 1:
$_columnCountDesktop = Mage::helper('themeframework/settings')->getProductsGrid_Onecolumn(5);
$_columnCountDesktopSmall = Mage::helper('themeframework/settings')->getProductsGrid_DesktopSmallOnecolumn(5);
$_columnCountTablet = Mage::helper('themeframework/settings')->getProductsGrid_TabletOnecolumn(5);
break;
default:
$_columnCountDesktop = Mage::helper('themeframework/settings')->getProductsGrid_Twocolumns(4);
$_columnCountDesktopSmall = Mage::helper('themeframework/settings')->getProductsGrid_DesktopSmallTwocolumns(4);
$_columnCountTablet = Mage::helper('themeframework/settings')->getProductsGrid_TabletTwocolumns(4); 
break;
}
$_columnCountMobile = Mage::helper('themeframework/settings')->getProductsGrid_ItemsMobile(3);
}else{
switch($_pageLayout){
case 3:
$_columnCountDesktop = Mage::helper('themeframework/settings')->getProductsGrid_Threecolumns(3);                    
break;
case 1:
$_columnCountDesktop = Mage::helper('themeframework/settings')->getProductsGrid_Onecolumn(5);
break;
default:
$_columnCountDesktop = Mage::helper('themeframework/settings')->getProductsGrid_Twocolumns(4); 
break;
}               
}
endif; ?>

<div class="toolbar-bottom em-box-03">
<?php echo $this->getToolbarHtml() ?>
</div>
</div>
<?php endif; ?>
<!--  colorswatch -->
<?php
// Provides a block where additional page components may be attached, primarily good for in-page JavaScript
if ($this->getChild('after')) {
$_afterChildren = $this->getChild('after')->getSortedChildren();
foreach ($_afterChildren as $_afterChildName) {
$_afterChild = $this->getChild('after')->getChild($_afterChildName);
//set product collection on after blocks
$_afterChild->setProductCollection($_productCollection);
echo $_afterChild->toHtml();
}
}
?>
  1. 其次,在管理面板中使用您的详细信息创建CMS页面。在内容选项卡中添加下面的代码

    {{{block type =“ catalog/product_special” template =“目录/product/sales_specials.phtml”}}}

在设计选项卡中,请选择您的布局作为2列,左栏和自定义布局更新XML XML写入以下代码。

<reference name="content">
<block after="-" type="catalog/product_list" name="offerte.new" alias="offerte" template="catalog/product/sales_specials.phtml">
<action method="setProductsCount"><count>15</count></action>
</block>
</reference>
许可以下: CC-BY-SA归因
scroll top