2012-03-18 27 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");