【问题标题】:Unable to find setIsInProcess() function definition找不到 setIsInProcess() 函数定义
【发布时间】:2018-03-16 19:01:36
【问题描述】:

我正在尝试以编程方式为已开票的订单创建发货,但我无法使其正常工作,因为订单中的所有商品都已正确创建发货,但订单状态仍然存在处理”而不是“完成”。

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

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

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

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

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

【问题讨论】:

    标签: php magento magento2 magento2.1


    【解决方案1】:

    setIsInProcess($value) 方法是对应模型的setData('is_in_process', $value) 的别名。您可以在父类Magento\Framework\Model\AbstractExtensibleModelMagento\Framework\Model\AbstractModel 中找到它的定义。 magic 方法是在父类(通常针对所有模型)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)。我认为这与你的问题有关,因为这里的订单状态和状态正在更改为处理中。

    【讨论】:

    • 感谢您的回复,我会接受的。澄清一下:所以这意味着 sales_order 模型中应该有一个“is_in_process”属性/字段可以设置为真/假。可能它被映射到 state = 'processing'。我的猜测对吗?我对 Magento 还很陌生,还在为它的魔力而苦苦挣扎:)
    • @sissy 只用在一个地方:第41行的Magento\Sales\Model\ResourceModel\Order\Handler\State::check(Order $order)。我认为这与您的问题有关,因为这里的订单状态和状态正在更改为处理中。是的,你是对的:)
    • 再次感谢,非常好的提示,但不幸的是,这并不能解决我的其他问题。我昨天问了一个问题stackoverflow.com/questions/46563363/…,甚至评论了setIsInProcess,或者试图强制一个完整的状态,我的订单仍然在处理中,并且物品的发货数量仍然是0。你那里也有线索吗?提前致谢。
    猜你喜欢
    • 2021-01-23
    • 1970-01-01
    • 1970-01-01
    • 2012-07-25
    • 1970-01-01
    • 1970-01-01
    • 2012-09-17
    • 2012-10-03
    • 1970-01-01
    相关资源
    最近更新 更多