-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix stock import for Product Variants #1490
base: 6.x
Are you sure you want to change the base?
Conversation
src/elements/CommerceProduct.php
Outdated
if (!$inventoryItem) { | ||
// Not tracking, never mind! | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I didn't consider when writing this (but I think is working as intended) is what would happen if the import itself turned on inventoryTracked
for a variant. Given that at this stage of the import, the variant has been saved with its native attributes, the inventory item would exist already… right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Yes, it does! Pushed another commit that rearranges some tests and clarifies how we're determining whether stock can/should be updated.)
Edit: I originally only saw one place we were saving an inventory item—but a record is always created as soon as a purchasable is saved. This means both that the existence of an InventoryItem
record isn't really an indication of anything, and I ought to have been checking for $variant->inventoryTracked
from the beginning!
Description
Fixes issues with importing variants for new products and various properties (including stock) for new variants.
Fixes issues with updating the variant‘s properties.
Related issues
#1457