2

我正在尝试以编程方式为已开票的订单创建装运,但我无法使其正常工作,因为订单中的所有项目都正确创建了装运,但订单状态仍然是“处理中”去“完成”。

我在发货的产品上发现了一个问题,因为它们的数量在发货创建后保持为 0。我已经问过这个问题,但没有运气,所以我试图调试 Magento 核心函数以弄清楚发生了什么,但我找不到setIsInProcess()函数的定义位置。

我已经搜索了模块销售的所有课程,但没有运气。

有人能告诉我在哪里可以找到这种方法吗?它由Sales\Orderlike 拥有和使用$order->setIsInProcess(true),但我function setIsInProcess(....)无处可寻。

我显然也从命令行搜索了grep所有文件的内部。.php

有什么线索吗??????请我从 2 天以来一直在苦苦挣扎!

4

1 回答 1

2

setIsInProcess($value)方法是setData('is_in_process', $value)相应模型的别名。您可以在父类Magento\Framework\Model\AbstractExtensibleModelMagento\Framework\Model\AbstractModel. 魔术方法是在方法的父类(通常针对所有模型)Magento\Framework\DataObject中实现的__call

/**
 * Set/Get attribute wrapper
 *
 * @param   string $method
 * @param   array $args
 * @return  mixed
 * @throws \Magento\Framework\Exception\LocalizedException
 */
public function __call($method, $args)
{
    switch (substr($method, 0, 3)) {
        case 'get':
            $key = $this->_underscore(substr($method, 3));
            $index = isset($args[0]) ? $args[0] : null;
            return $this->getData($key, $index);
        case 'set':
            $key = $this->_underscore(substr($method, 3));
            $value = isset($args[0]) ? $args[0] : null;
            return $this->setData($key, $value);
        case 'uns':
            $key = $this->_underscore(substr($method, 3));
            return $this->unsetData($key);
        case 'has':
            $key = $this->_underscore(substr($method, 3));
            return isset($this->_data[$key]);
    }
    throw new \Magento\Framework\Exception\LocalizedException(
        new \Magento\Framework\Phrase('Invalid method %1::%2', [get_class($this), $method])
    );
}

在 magento 1 中使用了类似的东西,我建议你阅读Ryan Street 写的这篇文章

PS:它只用在一个地方:Magento\Sales\Model\ResourceModel\Order\Handler\State::check‌​(Order $order)第41行。我认为这与您的问题有关,因为这里的订单状态和状态正在更改为处理中。

于 2017-10-05T08:25:32.767 回答