Magento Tablerate.php - 我如何获得属性?

时间:2011-06-03 10:21:57

标签: magento

我想让我的表费率体积,即基于宽度,高度和深度的重量(对于笨重(但不重)的物品)。这些属性是设置的,我可以在我自己的Model / Flatrate.php模块中读取它们。

这适用于我自己的属性和权重的测量,这是一个内置属性:

if ($request->getAllItems())

{ foreach ($request->getAllItems() as $item)
  Mage::log($item->getShipping_height());

然而,当我在Tablerate.php中尝试相同时,它不起作用,即使在核心而不是我自己的模块中。我没有得到任何重量,高度,长度和深度。这些都不起作用,我确实在日志文件中输入了条目但没有标签:

    if ($request->getAllItems()) {
        foreach ($request->getAllItems() as $item) {
        Mage::log("Weight ".$item->getWeight."*");
        Mage::log("Height ".$item->getProduct()->getShipping_height()."*");
        Mage::log("Width ".$item->getShipping_width()."*");
        Mage::log("Depth ".$item->getShipping_length()."*");

有没有人有任何想法?

1 个答案:

答案 0 :(得分:0)

这有效:

    if ($request->getAllItems()) {
        foreach ($request->getAllItems() as $item) {
        $item_ID = $item->getProductId();
        $_Product = Mage::getModel('catalog/product')->load($item_ID);

        Mage::log("Weight ".$_Product->getWeight."*");
        Mage::log("Height ".$_Product->getShipping_height()."*");
        Mage::log("Width ".$_Product->getShipping_width()."*");
        Mage::log("Depth ".$_Product->getShipping_length()."*");