Raf

Magento Order was not created. Reason: Unable to save Stock Item / Reason: Unique constraint violation found

Recommended Posts

Hi

Fresh install of Magento 2.2.2 and Ess_M2ePro 1.3.2 through Magento Marketplace
Only 3rd party eBay listings.

When item is sold on eBay new product in Magento is created, but customers and orders are not created.


Usually it looks like that:

Magento -> ebay integration -> Sales -> Orders Logs & Events -> eBay order -> Order Log

5 Jan 2018, 21:26:40     Magento Order was not created. Reason: Unable to save Stock Item
5 Jan 2018, 21:32:05     Magento Order was not created. Reason: Unique constraint violation found


I have also another installation of Magento ver. 1.9.3.7 with m2epro_ebay_magento 6.4.13 (stable)  on different hosting where everything works fine.
 

 

 

 

 

 

 

   

Share this post


Link to post
Share on other sites

Investigating problem further:

Once item is sold on eBay Magento product is created with empty quantity and "out of stock".
Once I update Magento product with some quantity and change stock status to "In Stock" order/invoice/customer is created after next cron run.

So I believe problem starts with importing eBay's product's quantity when created in Magento by m2epro.

 

 

Share this post


Link to post
Share on other sites

Hi!
I have found some information. Firstly, I recommend you to check the following settings:

  1. Set "Import eBay Orders:" = Yes
  2. Product Is Listed By Any Other Software > Create Order in Magento = Yes.
  3. Also, you need to enable New Customer Creation (see the screenshots below).

Note: The latter setting will set M2E Pro to collect orders for eBay listings that you did not list via M2E Pro.

Well, I have also found some links, hope, they will be helpful.
https://stackoverflow.com/questions/21458694/m2epro-ebay-order-in-magento-are-not-created

https://magento.stackexchange.com/questions/56424/magento-admin-not-able-to-create-new-customer-while-creating-new-order

It seems to me, that there is a conflict or some files are missing.

 

Screenshot (12).png

Screenshot (11).png

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, primavera said:

Hi!
I have found some information. Firstly, I recommend you to check the following settings:

  1. Set "Import eBay Orders:" = Yes
  2. Product Is Listed By Any Other Software > Create Order in Magento = Yes.
  3. Also, you need to enable New Customer Creation (see the screenshots below).

Note: The latter setting will set M2E Pro to collect orders for eBay listings that you did not list via M2E Pro.

Well, I have also found some links, hope, they will be helpful.
https://stackoverflow.com/questions/21458694/m2epro-ebay-order-in-magento-are-not-created

https://magento.stackexchange.com/questions/56424/magento-admin-not-able-to-create-new-customer-while-creating-new-order

It seems to me, that there is a conflict or some files are missing.

 

Screenshot (12).png

Screenshot (11).png

Thanks for reply but all of this is about Magento 1.9 with m2epro and it works as expected.

I'm having problem with Magento 2.2.2 and Ess_M2ePro 1.3.2

Share this post


Link to post
Share on other sites

Oh, sorry(

I also asked my colleague about this kind of issue. He told me that (if I am not mistaking) starting from Magento 2.1.8. the issues can occur if Magento Index is scheduled. As a temporary solution, you can try to enable Immediate Indexing. Hope, this helps. If no, it is better to contact M2E Support Team and ask for a piece of advice.

Share this post


Link to post
Share on other sites
30 minutes ago, primavera said:

Oh, sorry(

I also asked my colleague about this kind of issue. He told me that (if I am not mistaking) starting from Magento 2.1.8. the issues can occur if Magento Index is scheduled. As a temporary solution, you can try to enable Immediate Indexing. Hope, this helps. If no, it is better to contact M2E Support Team and ask for a piece of advice.

I though M2ePro Support Team sometimes have a look at their forum.

Share this post


Link to post
Share on other sites

I assume that something is wrong with your environment, but I am not sure, the investigation is needed. In your case it is necessary to give a support representative an opportunity to check it personally, to see what can be wrong. I just meant that in order to check if everything is alright with your system, support representatives will need your credentials etc. This information is confidential, and it is not a good idea to share it here:)

Share this post


Link to post
Share on other sites

@Raf  did this get resolved for you, I'm having the same issue with Amazon Integration. however I don't get that second log line regarding  Unique constraint violation found.

image.thumb.png.43ccd894cdac471e4c60cd2aad821918.png

image.thumb.png.29e1988e30eaaa4b885753e1f78c0e5b.png

Edited by Nathan Day

Share this post


Link to post
Share on other sites

An update for anyone else having this issue, The issue turned out to be that the Magento 2 Extension attempts to create a Stock Item, because the product has already been saved (Which creates a stock item) the extensions is unable to create a new one due to duplicates, Instead what should happen is after a product is saved it should load the existing stock item and modify it as required. 

 

The offending can can be found here:

vendor/m2epro/magento2-extension/Model/Magento/Product/Builder.php

 

and can be fixed by replacing the createStockItem function with the following code

private function createStockItem()
{
  /** @var $stockItem \Magento\CatalogInventory\Model\Stock\Item */
  $stockItem = $this->stockRegistry->getStockItem($this->product->getId());
  $stockItem
    ->setQty($this->getQty())
    ->setIsInStock(true)
    ->setUseConfigBackorders(true);
  $this->stockRegistry->updateStockItemBySku($this->product->getSku(), $stockItem);
}

 

hope this helps you.

Share this post


Link to post
Share on other sites

Hi, hope my snippet helps you. I also came across an issue regarding 3rd party listings, Don't  know if your issue is the same but when creating a new product from a third party listing m2epro wasn't correctly setting the quantity. For example if a 3p listing had 20 listed but an order came through for 2 the product qty would only be set to 2. I did also work out what was causing this and overrided it my own extension. I'm afk  right now so will post the code I used to fix that when I'm at my PC.

Edited by Nathan Day
Spelling correction

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.