Magento-在Mage_Sales_Model_Order.php中访问产品自定义属性值

Magento-在Mage_Sales_Model_Order.php中访问产品自定义属性值,magento,Magento,我正试图通过Mage_Sales_Model_Order.php中的一个自定义属性,通过$handlingtime=$this->getProduct()->getAttributeText('fig_handling_time'),访问特定产品的处理时间 但每次我发送订单电子邮件时,我都会收到错误致命错误:在第1320行的/home/japena/public\u html/app/code/local/Mage/Sales/Model/order.php中对非对象调用成员函数getAttri

我正试图通过Mage_Sales_Model_Order.php中的一个自定义属性,通过
$handlingtime=$this->getProduct()->getAttributeText('fig_handling_time'),访问特定产品的处理时间

但每次我发送订单电子邮件时,我都会收到错误
致命错误:在第1320行的/home/japena/public\u html/app/code/local/Mage/Sales/Model/order.php中对非对象调用成员函数getAttributeText()

我已经研究了一整天,尝试了许多不同的代码,并得出结论,我无法访问产品
$this->getProduct()
Mage::getModel('catalog/product')
,我也尝试过

$\u product=Mage::getModel(“目录/产品”)->load($\u product->getId());
$handlingtime=$\u product->getData('fig\u handlingtime')

$product=Mage::getModel('catalog/product')->load($item->getId())
$handlingtime=$product->getAttributeText('fig_handlingtime')

$handlingtime=Mage::getModel('catalog/product')->load($_item['product\u id'))->getAttributeText('fig\u handling\u time')

$handlingtime=Mage::getModel('catalog/product')->load($product\u id)->getAttributeText('fig\u handling\u time')


任何想法似乎都不管用,我将不胜感激。

//首先获取属性id

$audienceAttributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product','session_audience');
//Now Load the attribute
$audienceAttribute = Mage::getModel('catalog/resource_eav_attribute')->load($audienceAttributeId);
//现在获取要用于细化属性值的产品集合。 //我只想要分组产品的属性值。您可以添加类别过滤器 这样

$productCollection = Mage::getModel('catalog/product')->getCollection()
->addStoreFilter(Mage::app()->getStore())
->addAttributeToSelect('session_audience')
->addAttributeToSort('session_audience', 'asc')
->addAttributeToFilter('type_id', array('eq' => 'grouped'));
//现在获取集合的产品ID

$productCollectionIds = $productCollection ->getAllIds();
//现在我们查询数据库以获取给定产品ID的属性值。 //请注意,我正在从catalog\u product\u entity\u varchar表中进行选择,因为这是我使用的属性类型。

$read = Mage::getSingleton('core/resource')->getConnection('core_read');
$select = $read->select();
$select->from('catalog_product_entity_varchar')
->where('attribute_id = ?', $audienceAttributeId)
->where('entity_id IN (?)', $productCollectionIds );

//print_r($select->__toString());die();

//Now get the ids for the attribute values.

$result = $read->query($select);
$attributeOptionIds = array();
while($row = $result->fetch()){
$attributeOptionIds = array_merge($attributeOptionIds, explode(',', $row['value']));
}
array_unique($attributeOptionIds);
//print_r($audienceOptions);die();
$filteredAudienceCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
->setPositionOrder('asc')
->setAttributeFilter($audienceAttributeId)
->setStoreFilter($audienceAttribute->getStoreId())
->addFieldToFilter('main_table.option_id', array('in' => $attributeOptionIds))
->load();
//现在将ID的实际值作为一个集合获取,并对这些值进行处理。

$read = Mage::getSingleton('core/resource')->getConnection('core_read');
$select = $read->select();
$select->from('catalog_product_entity_varchar')
->where('attribute_id = ?', $audienceAttributeId)
->where('entity_id IN (?)', $productCollectionIds );

//print_r($select->__toString());die();

//Now get the ids for the attribute values.

$result = $read->query($select);
$attributeOptionIds = array();
while($row = $result->fetch()){
$attributeOptionIds = array_merge($attributeOptionIds, explode(',', $row['value']));
}
array_unique($attributeOptionIds);
//print_r($audienceOptions);die();
$filteredAudienceCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
->setPositionOrder('asc')
->setAttributeFilter($audienceAttributeId)
->setStoreFilter($audienceAttribute->getStoreId())
->addFieldToFilter('main_table.option_id', array('in' => $attributeOptionIds))
->load();

如何搜索正在购买的特定项目的
fig\u处理时间
属性?->addAttributeToSelect('session\u观众')随您的自定义属性id更改