2013-05-03 117 views
3

在magento我想在我的主页上显示新产品。为此,我搜索了许多博客和论坛。 >首页内容我将获得新的产品 - 从所有这些我已经在CMS使用Magento新产品没有在主页上显示

{{block type="catalog/product_new" block_id="new.products" template="catalog/product/new.phtml"}}

明白了。但我仍然没有收到任何产品。此外,我试图改变活跃的日期。但它没有显示任何产品。那么有人可以告诉我这里有什么问题吗?任何帮助和建议都将非常可观。由于

回答

11

在默认的Magento实现catalog/product_new块的规则是:

  • 的产品应该是可见的目录

  • 产品应当具备两个news_from_datenews_to_date的属性设置为某个值

  • 属性news_from_date作品,直到今天的日期结束(23:59:59 ),并从今天开始的日期属性news_to_date作品(00:00:00)

当是至少有一种产品能够满足块要求的要求。同时清理缓存和重新索引数据也可以有所帮助。

+0

很好的答案,正是我要写的:) – Andrew 2013-05-03 09:05:25

+0

完美工作。谢谢。投票。 – 2015-12-19 05:53:55

0

试试这个 写入以下代码CMS->页面级>设计标签 - >布局更新XML

<reference name="content"> 
     <block type="catalog/product_list" name="featured" template="catalog/product/new.phtml"> 
     </block> 
    </reference> 

你必须添加new.phtml文件中的“应用程序\设计\前台\ DEFAULT \默认\模板\目录\产品”

写在new.phtml文件下面的代码

<?php 

/****************** 

     //Recently Added Products 

    ************************/ 
$_helper = $this->helper('catalog/output'); 
$_productCollection = Mage::getResourceModel('reports/product_collection') 
        ->addAttributeToSelect('*') 
        ->setVisibility(array(2,3,4))     
        ->setOrder('created_at', 'desc'); 

?> 


    <div style="clear: both;"></div> 

    <div id="block"> 
     <div class="text">Recently Added Products 
      <a href="<?php echo $this->getUrl("recent_added"); ?>" class="link"> View more &#187; </a> 
     </div> 
    </div> 

    <?php foreach($_productCollection as $_product) : ?> 
     <div class="grid"> 

      <div class="imgholder" > 
        <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(135); ?>" width="135" height="135" 
        alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a> 
      </div> 

      <strong><a href="<?php echo $_product->getProductUrl(); ?>" style="color:#039;"><?php echo $_product->getName(); ?></a></strong> 

      <p><?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?></p> 

      <div class="price"> 
      <?php echo $this->getPriceHtml($_product, true) ?> 
      </div> 

     </div> 

    <?php endforeach; ?> 
+0

感谢您的回复。但仍然不工作... – NewUser 2013-05-03 06:59:36

+0

你必须把你的phtml文件放在app \ design \ frontend \ default \ default \ template \ catalog \ product – 2013-05-03 07:25:30

0

您也可以使用Widget显示它。我的意思是通过在CMS主页中添加小部件。

0

我有这个问题,并与代理人交谈,代理人为我解决了这个问题,并解释它没有帮助。您需要将所有导航类别放入最高的根类别(因此所有类别都将看起来像第一个不能删除的第一个根类别的子类别,它们不能是或源自任何并列根类别,然后刷新您的索引和类别项目将出现在导航菜单

2

万一你会在这里结束,还有一个简单的解决方法试试:

系统 - >索引管理

和选择所有(即使他们表示“绿色,不需要重新索引”并强制它们重新索引。

这个解决方案d空的getSize()问题,这反过来又允许特殊和新数据库请求查找产品,实现“if”条件并正确呈现。

相关问题