找不到 setIsInProcess() 函数定义

Unable to find setIsInProcess() function definition

我正在尝试以编程方式为已开具发票的订单创建发货,但我无法使其正常工作,因为发货已正确创建,对于订单中的所有项目,但订单状态保持 'Processing' 而不是去 'complete'.

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

我搜索了模块销售的所有 类,但没有找到。

谁能告诉我在哪里可以找到这个方法?它归 Sales\Order 所有并像 $order->setIsInProcess(true) 一样使用,但我找不到 function setIsInProcess(....) 任何地方。

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

有线索吗?????拜托我已经苦苦挣扎了 2 天!

setIsInProcess($value)方法是对应模型setData('is_in_process', $value)的别名。您可以在父 class Magento\Framework\Model\AbstractExtensibleModelMagento\Framework\Model\AbstractModel 中找到它的定义。 magic 方法在父 class 中实现(通常用于所有模型) 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 中使用了类似的东西,我建议您阅读 this article written by Ryan Street

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