-
Notifications
You must be signed in to change notification settings - Fork 0
COMOPT-736 bundles support #7
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,11 +124,28 @@ function transformVariantValues(masterSku, variationValues) { | |
| } | ||
|
|
||
| /** | ||
| * Transforms a Salesforce product to an ACO product. | ||
| * Builds the bundles array for an ACO parent bundle product. | ||
| * | ||
| * @param {SalesforceProduct} product - The Salesforce product. | ||
| * @returns {import('@adobe-commerce/aco-ts-sdk').FeedProduct} The ACO product. | ||
| * @param {{ id: string; name: string; quantity: number }[]} bundledProducts - Array of bundled product objects | ||
| * @returns {object[]} Array of bundle group objects for ACO | ||
| */ | ||
| function buildAcoBundles(bundledProducts) { | ||
|
||
| if (!Array.isArray(bundledProducts) || bundledProducts.length === 0) return []; | ||
| return bundledProducts.map(bp => ({ | ||
| group: bp.name, | ||
| required: true, | ||
| multiSelect: false, | ||
| defaultItemSkus: [bp.id], | ||
| items: [ | ||
| { | ||
| sku: bp.id, | ||
| qty: bp.quantity, | ||
| userDefinedQty: false, | ||
| }, | ||
| ], | ||
| })); | ||
| } | ||
|
|
||
| const transformProduct = product => { | ||
| const acoProduct = { | ||
| sku: product.id, | ||
|
|
@@ -166,7 +183,6 @@ const transformProduct = product => { | |
| ...transformCustomAttributes(product.customAttributes), | ||
| ], | ||
| images: transformImages(product.images), | ||
| // TODO: Add bundle product support | ||
| }; | ||
|
|
||
| //add configurations | ||
|
|
@@ -182,11 +198,23 @@ const transformProduct = product => { | |
| sku: masterSku, | ||
| }, | ||
| ]; | ||
|
|
||
| //attributes | ||
| acoProduct.attributes.push(...transformVariantValues(masterSku, product.variationValues)); | ||
| } | ||
|
|
||
| // Handle parent bundle product (type BUNDLE) using correct bundles array structure | ||
| if (product.type === 'BUNDLE' && Array.isArray(product.bundledProducts) && product.bundledProducts.length > 0) { | ||
|
||
| acoProduct.bundles = buildAcoBundles(product.bundledProducts); | ||
| } | ||
|
|
||
| // Handle bundled products (child) for BUNDLED type | ||
| if (product.type === 'BUNDLED' && Array.isArray(product.bundles) && product.bundles.length > 0) { | ||
| acoProduct.links = product.bundles.map(bundleSku => ({ | ||
| type: 'in_bundle', | ||
| sku: bundleSku, | ||
| })); | ||
| } | ||
|
|
||
| // @ts-ignore | ||
| return acoProduct; | ||
| }; | ||
|
|
||
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.
It looks like the comment for
transformProductwas removed during this update. Can you add it back?