我有一個名爲位置要和地點從產品相關的2自定義選項的文本字段,如何從觀察者事件訪問Magento的產品的自定義選項
我已經設置了對checkout_cart_add_product_complete
觀察員一個模塊使用getLocationCoords方法,我將如何從傳遞給我的方法的事件對象訪問這兩個字段。
我需要這些2場,所以我可以反向地理他們,我想我能做到我自己。
一旦我得到了2套座標我將如何去與產品存儲他們,所以我能看到他們與該產品相關訂單一旦節奏?
======================= 編輯addded ==================== ========
我曾嘗試迄今
public function getLocationCoords(Varien_Event_Observer $observer)
{
// Retrieve the product being updated from the event observer
$product = $observer->getEvent()->getProduct();
// Write a new line to var/log/product-updates.log
$name = $product->getName();
$sku = $product->getSku();
Mage::log(
"{$name} ({$sku}) updated",
null,
'product-updates.log'
);
foreach ($product->getOptions() as $o) {
$type = "Custom Option TYPE: " . $o->getType();
$title = "Custom Option TITLE: " . $o->getTitle();
Mage::log(
"{$type} ({$title}) custom option {$o}",
null,
'product-updates.log'
);
}
}
它除了獲得的自定義選項的值的所有作品,我會嘗試下面的答案,看看我得到
當我打印出選項對象的var轉儲這是我得到
2012-12-11T15:19:45+00:00 DEBUG (7): array (
'option_id' => '1',
'product_id' => '1',
'type' => 'field',
'is_require' => '1',
'max_characters' => '0',
'sort_order' => '0',
'default_title' => 'Location To',
'title' => 'Location To',
'default_price' => '0.0000',
'default_price_type' => 'fixed',
'price' => '0.0000',
'price_type' => 'fixed',
)
沒有價值的對象
你讓我在正確的方向,但我發現我的選擇不同的方式,我已經回答下面 – molleman