几天前我在获取产品详细信息时遇到了一个问题。现在我已经解决了这个问题,并获得了所有的产品信息。但我不知道如何获得产品的公司地址,产品的过期日期和开始日期。
有人能告诉我密码是什么吗?我只需要四样东西。
- 产品公司名称
- 产品公司地址
- 产品开始日期
- 产品过期日期
以下是获取产品详细信息的代码:
$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();
您是否将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" );