[英]Magento: Get all shipping costs for all countries for a product in Magento backend
我目前正在開發 Magento(后端)插件來為產品創建小部件。 我現在花了 2 天時間嘗試獲取每個國家/地區的產品運費清單。
我得到了什么:
我有一個后端 controller 加載一個產品 model,我從這個 model 獲得了我需要的所有數據。
現在的問題是獲取已定義的每個國家/地區的運費清單。 我怎樣才能做到這一點?
對不起,我不能更具體,因為我沒有任何工作.. :(
感謝您的每一個幫助! 核磁共振
[編輯2]
我現在嘗試使用 ʍǝɥʇɐɯ 在他的回答評論中發布的前面示例(http://www.magentocommerce.com/magento-connect/EcomDev/extension/3860/ecomdev_productpageshipping)。 但這不起作用,我總是得到一個空數組。
$addToCartInfo = array("estimate"=> array("country_id"=> "US"), "product"=> "1", "related_product" => "", "qty" => "1" );
$product->setAddToCartInfo($addToCartInfo);
$quote = Mage::getModel('sales/quote');
$shippingAddress = $quote->getShippingAddress();
$shippingAddress->setCountryId('US');
$shippingAddress->setCollectShippingRates(true);
$request = new Varien_Object($addToCartInfo);
$request->setQty(1);
$quote->addProduct($product, $request);
$quote->collectTotals();
$rateResult = $shippingAddress->getGroupedAllShippingRates();
在這個例子中前端和后端之間有什么區別導致我不能使用這個代碼嗎? 我怎么能在后端做到這一點?
再次感謝,MRU
Magento 擴展上有一個模塊可以做到這一點 - 也許先看看它並重用他們的代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.