Open achadee opened 6 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?
Actually the existing value is being used, just has a default of 1. Never mind
What's the expected behaviour here @achadee ?
Option 1:
Value before update in Magento: Manage Stock = False Qty = 0 Is In Stock = False
Stock is changes in Ant HQ (need to push new stock to Magento)
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:
Value before update in Magento: Manage Stock = False Qty = 0 Is In Stock = False
Stock is changes in Ant HQ (need to push new stock to Magento)
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:
The only field that should be updated in an inventory update request is the "quantity" field any other fields should be ignored.
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
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.
Why does that happen?
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]
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