Skip to content
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

Open
wants to merge 9 commits into
base: 6.x
Choose a base branch
from
Open

Fix stock import for Product Variants #1490

wants to merge 9 commits into from

Conversation

lukeholder
Copy link
Member

@lukeholder lukeholder commented Aug 12, 2024

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

Comment on lines 515 to 518
if (!$inventoryItem) {
// Not tracking, never mind!
continue;
}
Copy link
Collaborator

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?

Copy link
Collaborator

@AugustMiller AugustMiller Aug 16, 2024

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!

@i-just i-just marked this pull request as ready for review September 3, 2024 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants