2020-12-01 15:14 阅读 0

MSI#822 Source deduction for virtual and downloadable products


Source Deduction logic for virtual and downloadable products.

Fixed Issues (if relevant)

  1. magento-engcom/msi#822: Downloadable and Virtual products remain In Stock after all quantity is bought.

Manual testing scenarios

  1. Create Virtual Product while using Single Stock Mode
  2. Buy the virtual product
  3. (Database check)
    • Reservation was created
    • Source items are not decreased yet
  4. Go to Sales > Orders in admin
  5. Select your order and create an invoice
  6. (Database check)
    • A new Reservation entry was created, which negotiates the first initial reservation
    • Source items are deducted by the invoiced quantity
  7. Create further sources and a new stock; assign your website to the new stock
  8. Assign the new sources to your virtual product and add some quantity
  9. Repeat order and invoicing and check the expected changes in database

Testing variations

  • Process an order with mixed product types (virtual, downloadable, simple, etc.)
  • Try partial invoicing (, : This could probably cause an issue with reservation cleanup...?)

Contribution checklist

  • [ ] Pull request has a meaningful description of its purpose
  • [ ] All commits are accompanied by meaningful commit messages
  • [ ] All new or changed code is covered with unit/integration tests (if applicable)
  • [ ] All automated tests passed successfully (all builds on Travis CI are green)


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

5条回答 默认 最新

  • weixin_39765695 weixin_39765695 2020-12-01 15:14

    / I have problems with integration tests in this issue. For me it seams to be a M2 core problem. I use \Magento\Quote\Api\CartManagementInterface::placeOrder in order to create orders within the fixtures. The implementation for placeOrder loads quote like following:

         * {}
        public function placeOrder($cartId, PaymentInterface $paymentMethod = null)
            $quote = $this->quoteRepository->getActive($cartId);

    The interface for getActive has a second optional parameter:

         * Get active quote by id
         *  int $cartId
         *  int[] $sharedStoreIds
         *  \Magento\Quote\Api\Data\CartInterface
         *  \Magento\Framework\Exception\NoSuchEntityException
        public function getActive($cartId, array $sharedStoreIds = []);

    Since $sharedStoreIds is not set the returned quote is always assigned to the default store.

    Do I need create orders in fixtures in any other way? Or is this a bug in core?

    点赞 评论 复制链接分享
  • weixin_39765695 weixin_39765695 2020-12-01 15:14

    The given problem with integration tests was formed as an own issue: https://github.com/magento-engcom/msi/issues/977

    点赞 评论 复制链接分享
  • weixin_39765695 weixin_39765695 2020-12-01 15:14

    your requested changes are done. Request for feedback :)

    点赞 评论 复制链接分享
  • weixin_39644750 weixin_39644750 2020-12-01 15:14


    点赞 评论 复制链接分享
  • weixin_39618176 weixin_39618176 2020-12-01 15:14

    I'm seeing this issue:

    Fatal error: Uncaught Error: Call to a member function getIsVirtual() on null in /home/ccarnell/Sites/vax-uk2/vendor/magento/module-inventory-shipping/Observer/VirtualSourceDeductionProcessor.php:160 Stack trace: #0 /home/ccarnell/Sites/vax-uk2/vendor/magento/module-inventory-shipping/Observer/VirtualSourceDeductionProcessor.php(148): Magento\InventoryShipping\Observer\VirtualSourceDeductionProcessor->hasValidItems(Object(Magento\Sales\Model\Order\Invoice)) #1 /home/ccarnell/Sites/vax-uk2/vendor/magento/module-inventory-shipping/Observer/VirtualSourceDeductionProcessor.php(92): Magento\InventoryShipping\Observer\VirtualSourceDeductionProcessor->isValid(Object(Magento\Sales\Model\Order\Invoice)) #2 /home/ccarnell/Sites/vax-uk2/vendor/magento/framework/Event/Invoker/InvokerDefault.php(72): Magento\InventoryShipping\Observer\VirtualSourceDeductionProcessor->execute(Object(Magento\Framework\Event\Observer)) #3 /home/ccarnell/Sites/vax-uk2/vendor/magento/framework/Event/Invoker/InvokerDefault.php(60): Magento\Framework\Event\I in /home/ccarnell/Sites/vax-uk2/vendor/magento/module-inventory-shipping/Observer/VirtualSourceDeductionProcessor.php on line 160
    点赞 评论 复制链接分享