ant-hq / magento-module

MIT License
0 stars 0 forks source link

Manage stock should not be updating during inventory updates #2

Open achadee opened 6 years ago

achadee commented 6 years ago

https://github.com/ant-hq/magento-module/blob/c40333eb48f1cca1f6fe9accb49aa92eea398370/ant_api/app/code/community/Ant/Api/Model/Api2/Inventory/Rest/Guest/V1.php#L13

and

https://github.com/ant-hq/magento-module/blob/c40333eb48f1cca1f6fe9accb49aa92eea398370/ant_api/app/code/community/Ant/Api/Model/Api2/Inventory/Rest/Admin/V1.php#L13

PivitParkour94 commented 5 years ago

Should this be forcing a manage_stock value of 1 here too? /app/code/community/Ant/Api/Helper/Data.php:1037 if so, why not force it to 1 for both the Guest and Admin Rest objects?

PivitParkour94 commented 5 years ago

Actually the existing value is being used, just has a default of 1. Never mind

tschirmer commented 5 years ago

What's the expected behaviour here @achadee ?

Option 1:

  1. Value before update in Magento: Manage Stock = False Qty = 0 Is In Stock = False

  2. Stock is changes in Ant HQ (need to push new stock to Magento)

  3. Value before update in Magento: Manage Stock = True Qty = 10 Is In Stock = True

Result of Option 1: Stock has changed from unavailable to available, regardless of what was set in Magento prior.

Option 2:

  1. Value before update in Magento: Manage Stock = False Qty = 0 Is In Stock = False

  2. Stock is changes in Ant HQ (need to push new stock to Magento)

  3. Value before update in Magento: Manage Stock = False Qty = 10 Is In Stock = True

Result of Option 2: Stock remains untracked. More than 10 can be sold,and Qty is ignored. But What was set in Magento is persisted.

Alternative Option:

achadee commented 5 years ago

The only field that should be updated in an inventory update request is the "quantity" field any other fields should be ignored.

achadee commented 5 years ago

some of our legacy code might still provide the field manage_stock this field needs to be ignored even though its provided. If the customer wishes to change the manage stock value they can publish the product again from ant or change it in magento and the webhook should change it in Ant

tschirmer commented 5 years ago

Ok, we can do that.

Just so you're aware, that with that behaviour, there may be circumstances where Magento may mark the product as "not saleable" on the website, even after a full sync when there is qty available in AntHQ.

achadee commented 5 years ago

Why does that happen?

tschirmer commented 5 years ago

Just going over the Magento Inventory, and having a non-salable won't happen without changing the is_in_stock incorrectly, however, we could sell more than the qty available in this circumstance:

Manage Stock = False (turned to false by a user) Qty = 0 Is In Stock = True

[Stock is changes in Ant HQ (need to push new stock to Magento)]

Manage Stock = False (not changed by AntHQ Sync) Qty = 10 (This is now ignored due to the setting above) Is In Stock = True

[can will sell more than 10]