获取magento中的产品到期日期和公司地址

时间:2012-03-18 06:14:22

标签: php magento

几天前我遇到了一个问题,无法获得产品详细信息。现在我已经解决了这个问题,并获得了所有产品信息。但我不知道如何获得产品公司地址,产品过期日期和开始日期。

有人可以告诉我代码是什么吗?我只需要四件事。

  • 产品公司名称
  • 产品公司地址
  • 产品开始日期
  • 产品过期日期

以下是获取产品详细信息的代码:

$obj = Mage::getModel('catalog/product');
 $_product = $obj->load($item_ID); 

 $pname = $_product->getName();
 $psdes = $_product->getShortDescription();
 $pdes = $_product->getDescription();
 $pprice = $_product->getPrice();
 $psprice = $_product->getSpecialPrice();
 $pimage = $_product->getImageUrl();

1 个答案:

答案 0 :(得分:0)

您是否正在将Magento Enterprise版与目录事件一起使用?如果您的产品属于具有事件的类别,则它将具有结束日期和开始日期。如果是这样,您就可以获得产品开始日期和产品结束日期。

//first you need to get the event associated with the product
$event = $product->getEvent();

//now, let's work with the start date
$startdate = new DateTime($event->getData('date_' . 'start'));

//you now have a DateTime object which you can turn into a String as follows
//note that you can change the formatting according to the rules here 
//http://www.php.net/manual/en/function.date.php

$startdate = date_format($startdate, "d-m-Y H:i" );

//now here is the end date
$enddate = new DateTime($event->getData('date_' . 'end'));
$enddate = date_format($enddate, "d-m-Y H:i" );