【问题标题】:How can I get Product Custom Attribute in custom shipping module (Magento 2)?如何在自定义运输模块(Magento 2)中获取产品自定义属性?
【发布时间】:2017-10-13 20:03:50
【问题描述】:

我正在尝试将产品自定义属性提取到我的自定义运输模块。但无法这样做。 我尝试了论坛的各种问题,但我的问题仍然没有解决。 question:Magento 2 get custom Product Attribute from shipping

但是没有任何效果。 我创建了一个名为 volweight 的自定义属性 我的文件被放置在 app\code{MODULE_name}\CustomShipping\Model\Carrier\Custom.php

$id = 5;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->get('\Magento\Catalog\Model\Product')->load($id);
$productweight  =   $product->getData('volweight');
$this->logger->debug('PID: ', $productweight);

我用来检查我的答案是否正确的记录器。

【问题讨论】:

    标签: magento e-commerce magento2 custom-attributes


    【解决方案1】:
    foreach ($request->getAllItems() as $item){
                $product = $item->getProduct();
                $product->load($item->getProduct()->getId());
                
                $attribute = $product->getData('attribute_code'));
    }
    

    【讨论】:

      猜你喜欢
      • 2016-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-06
      • 1970-01-01
      • 2013-04-10
      • 1970-01-01
      • 2016-11-24
      相关资源
      最近更新 更多