2012-03-18 86 views
0

我有一个问题,几天后才能得到产品的详细信息。现在我已经解决了这个问题并获得了所有的产品信息。但我不知道如何获取产品公司地址,产品过期日期和开始日期。获取产品的有效期限和公司地址在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(); 
+0

取决于属性的属性代码是什么。例如如果公司名称的属性代码是company_name,请尝试$ _product-> getCompanyName(); – sulabh 2012-03-18 06:20:15

回答

0

你在使用Magento Enterprise editio吗?与目录事件?如果您的产品属于具有事件的类别,则它将具有结束日期和开始日期。如果是这样,那么您将如何获得产品开始日期和产品结束日期。

//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");