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

Update variant name, price and stock through the DFC API #12037

Merged
merged 6 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def self.import_product(supplied_product)

def self.apply(supplied_product, variant)
variant.product.assign_attributes(
name: supplied_product.name,
description: supplied_product.description,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be a problem for description also?
Or do we need to keep this in order to achieve the current project..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be a problem for description also?

Yes, variants don't have descriptions, only products do. And when you change it through one variant then all get changed. It's a limitation we can't avoid at the moment. Better than no description update at all.

)

variant.display_name = supplied_product.name
QuantitativeValueBuilder.apply(supplied_product.quantity, variant.product)
variant.unit_value = variant.product.unit_value
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
submit_request(example.metadata)
variant.reload
}.to change { variant.description }.to("DFC-Pesto updated")
.and change { variant.name }.to("Pesto novo")
.and change { variant.display_name }.to("Pesto novo")
.and change { variant.unit_value }.to(17)
end
end
Expand Down
2 changes: 1 addition & 1 deletion swagger/dfc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ paths:
"@context": https://www.datafoodconsortium.org
"@id": http://test.host/api/dfc/enterprises/10000/supplied_products/10001
"@type": dfc-b:SuppliedProduct
dfc-b:name: Apple - 6g
dfc-b:name: Apple (6g)
dfc-b:description: A delicious heritage apple
dfc-b:hasType: dfc-pt:non-local-vegetable
dfc-b:hasQuantity:
Expand Down