2
votes

I'm trying to programatically create shipment for orders that are already invoiced, but I cannot manage to make it work, in the sense that the shipment is correctly created, for all the items in the order, but order status remains 'Processing' instead of going to 'complete'.

I found an issue on shipped products,as their quantity stays to 0 after shipment creation. I've already asked about this, with no luck, so I'm trying to debug Magento core functions in order to figure out what is going on, but I cannot find where the setIsInProcess() function is defined.

I've searched in all the classes of the module-sales but no luck.

Can somenone tell me where to find this method? It is owned by Sales\Order and used like $order->setIsInProcess(true), but i cannot find function setIsInProcess(....) nowhere.

I've obviously also searched with a grep inside all .php files from command line.

Any clue????? Please I'm struggling since 2 days!

1

1 Answers

2
votes

The setIsInProcess($value) method is an alias for the setData('is_in_process', $value) of corresponding model. You can find it's definition in the parent class Magento\Framework\Model\AbstractExtensibleModel or in the Magento\Framework\Model\AbstractModel. The magic methods is realised in the parent class (usually for all the models) Magento\Framework\DataObject in the __call method:

/**
 * 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])
    );
}

Something similar was used in the magento 1, and I'll recommend you to read this article written by Ryan Street

PS: It is used just in one place: Magento\Sales\Model\ResourceModel\Order\Handler\State::check‌​(Order $order) on line 41. I think it is related to your problem, because here the order state and status is changing to the processing.