我正在尝试以编程方式为已开具发票的订单创建发货,但我无法使其正常工作,因为对于订单中的所有商品都正确创建了发货,但订单状态仍为“正在处理”而不是“完成”。
我发现已发货产品存在问题,因为在创建发货后其数量仍为 0。我已经问过这个问题,但没有运气,所以我尝试调试 Magento 核心功能以弄清楚发生了什么,但我找不到 setIsInProcess()
在哪里函数已定义。
我已经搜索了模块销售的所有类别,但没有成功。
有人可以告诉我在哪里可以找到这个方法吗?它的所有者是 Sales\Order
并像$order->setIsInProcess(true)
一样使用,但我找不到function setIsInProcess(....)
无处。
我显然也用 grep
进行了搜索里面全部.php
来自命令行的文件。
有什么线索吗????拜托,我已经挣扎了两天了!
最佳答案
setIsInProcess($value)
方法是相应模型的 setData('is_in_process', $value)
的别名。您可以在父类 Magento\Framework\Model\AbstractExtensibleModel
或 Magento\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 中使用了类似的东西,我建议您阅读 this article written by Ryan Street
PS:它仅在一个地方使用:Magento\Sales\Model\ResourceModel\Order\Handler\State::check(Order $order)
第41行。我认为这与您的问题有关,因为这里订单状态和状态正在更改为正在处理。
关于php - 找不到 setIsInProcess() 函数定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46580880/