2017-10-05 80 views
2

我试图以编程方式为已经开具发票的订单创建装运,但我无法设法使其工作,因为正确创建了装运,对于所有物品订单,但订单状态保持'处理'而不是'完成'。无法找到setIsInProcess()函数定义

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

我已经在模块的所有类中搜索过销售,但没有运气。

可以somenone告诉我在哪里可以找到这个方法吗?它由Sales\Order拥有,并使用像$order->setIsInProcess(true),但我无法找到function setIsInProcess(....)无处。

我明显还用grep搜索了所有.php文件中的命令行。

任何线索?????请让我在2天内挣扎!

回答

1

setIsInProcess($value)方法是相应模型的setData('is_in_process', $value)的别名。您可以在父类Magento\Framework\Model\AbstractExtensibleModelMagento\Framework\Model\AbstractModel中找到它的定义。该魔术方法是在__call方法(通常为所有型号)Magento\Framework\DataObject父类实现:

/** 
* 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行。我认为这与你的问题有关,因为这里的订单状态和状态正在改变为处理。

+0

谢谢您的回复,我会接受。只是澄清一下:所以这意味着sales_order模型中应该有一个'is_in_process'属性/字段可以设置为true/false。可能它被映射到state ='processing'。我的猜测是对的吗?我对Magento非常陌生,但仍然在为它的魔力挣扎:) – sissy

+0

@sissy它只用在一个地方:'Magento \ Sales \ Model \ ResourceModel \ Order \ Handler \ State :: check(Order $ order)'on第41行。我认为这与你的问题有关,因为这里的订单状态和状态正在改变为处理。是的,你是对的:) –

+0

再次感谢,非常好的提示,但不幸的是这并不能解决我的其他问题。我昨天问了一个问题https://stackoverflow.com/questions/46563363/creating-shipment-does-not-update-items-shipped-quantity-and-order-is-not-comple,甚至评论setIsInProcess,或尝试强制一个完整的状态,我的订单仍然处理和项目发货数量仍然是0.你是否也有线索?提前致谢。 – sissy