2

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!

sissy
  • 2,908
  • 2
  • 28
  • 54

1 Answers1

2

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.

  • Thank you for your reply, i will accept it. Just a clarification: so it means that there should be a 'is_in_process' attribute/field in the sales_order model that can be set to true/false. Probably it is mapped to state = 'processing'. Is my guess right? I'm pretty new to Magento and still struggling with its magics :) – sissy Oct 05 '17 at 08:41
  • @sissy 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. And yes, you are right :) – Siarhey Uchukhlebau Oct 05 '17 at 08:47
  • Thanks again, very good hints, but unfortunately this doesn't solve my other problem. I asked a question yesterday https://stackoverflow.com/questions/46563363/creating-shipment-does-not-update-items-shipped-quantity-and-order-is-not-comple and even commenting the setIsInProcess, or trying to force a complete state, my orders remain Processing and items Shipped quantity is still 0. Do you also have a clue there? thanks in advance. – sissy Oct 05 '17 at 09:09