2010-11-19 97 views
1

我需要在Magento主页上自动显示3个左右的新产品。这意味着管理员不必使用“常规”选项卡中的“从新建日期”和“新到日期”属性将产品标记为新建。我知道如何自动创建一个包含新产品的单独类别,但是如何在主页上显示它们?如何在Magento主页上自动显示新产品?

回答

0

您必须为此类系统属性设置新模型。 首先编辑* eav_attribute *表Magento的mysql数据库

随时随地编辑“news_to_date”记录,并从“EAV/entity_attribute_backend_datetime”为“目录/ product_attribute_backend_newsto”设置后端模式

现在去核/目录/型号/产品/属性/后端并创建一个新的文件“Newsto.php”

写这段代码在这个文件不是储蓄

class Mage_Catalog_Model_Product_Attribute_Backend_Newsto extends Mage_Eav_Model_Entity_Attribute_Backend_Datetime 
{ 
    public function beforeSave($object) 
    { 
     $attributeName = $this->getAttribute()->getName(); 
     $startDate  = $object->getData('news_from_date'); 
     $toDate   = $object->getData($attributeName); 

     if ($toDate === false) { 
      return $this; 
     } 
     if ($toDate == '' && $startDate != '') {   
     $newdate = strtotime($startDate);    
     $toDate = date("d/m/Y",strtotime("+7 days",$newdate)); 
     } 

     $object->setData($attributeName, $toDate); 

     parent::beforeSave($object); 
     return $this; 
    } 

} 
0

我想你可以,如果你建立一个自定义布局为您的主页,并选择显示的东西不是基于新的标准,但基于给定的类别。从来没有这样做,所以它只是一个建议,在这个方向进行研究。

相关问题