Skip to content

Instantly share code, notes, and snippets.

@mghdotdev
Last active July 25, 2018 21:20
Show Gist options
  • Save mghdotdev/b6a944572fc9f7bb3ff53eb079b58b7c to your computer and use it in GitHub Desktop.
Save mghdotdev/b6a944572fc9f7bb3ff53eb079b58b7c to your computer and use it in GitHub Desktop.
Master/Variant Provisioning Workflow
<!-- ==================== START MASTER ==================== -->
<!-- ADD MASTER PRODUCT -->
<Product_Add>
<Code>tshirt</Code>
<!--
...
...
...
-->
<Active>Yes</Active>
</Product_Add>
<!-- ADD MASTER PRODUCT ATTRIBUTE(S) -->
<ProductAttribute_Add product_code="tshirt">
<Code>size</Code>
<Type>select</Type>
<Prompt><![CDATA[Size]]></Prompt>
<Required>Yes</Required> <!-- "Yes" if you plan on assigning variants to this attribute -->
<Inventory>Yes</Inventory> <!-- "Yes" if you plan on assigning variants to this attribute -->
</ProductAttribute_Add>
<ProductAttribute_Add product_code="tshirt">
<Code>color</Code>
<Type>swatch-select</Type>
<Prompt><![CDATA[Color]]></Prompt>
<Required>Yes</Required> <!-- "Yes" if you plan on assigning variants to this attribute -->
<Inventory>Yes</Inventory> <!-- "Yes" if you plan on assigning variants to this attribute -->
</ProductAttribute_Add>
<!-- ADD MASTER PRODUCT ATTRIBUTE OPTION(S) -->
<!-- size -->
<ProductAttributeOption_Add product_code="tshirt" attribute_code="size">
<Code>small</Code>
<Prompt><![CDATA[Small]]></Prompt>
<DefaultOption>Yes</DefaultOption> <!-- Assign "Yes" to only one of the options | "No" to all if you want a "Select One" prompt (no default options selected) -->
</ProductAttributeOption_Add>
<ProductAttributeOption_Add product_code="tshirt" attribute_code="size">
<Code>medium</Code>
<Prompt><![CDATA[medium]]></Prompt>
<DefaultOption>No</DefaultOption>
</ProductAttributeOption_Add>
<ProductAttributeOption_Add product_code="tshirt" attribute_code="size">
<Code>large</Code>
<Prompt><![CDATA[Large]]></Prompt>
<DefaultOption>No</DefaultOption>
</ProductAttributeOption_Add>
<!-- color -->
<ProductAttributeOption_Add product_code="tshirt" attribute_code="color">
<Code>red</Code>
<Prompt><![CDATA[Red]]></Prompt>
<DefaultOption>Yes</DefaultOption> <!-- Assign "Yes" to only one of the options | "No" to all if you want a "Select One" prompt (no default options selected) -->
<Image>graphics/00000001/redimage.jpg</Image>
</ProductAttributeOption_Add>
<ProductAttributeOption_Add product_code="tshirt" attribute_code="color">
<Code>blue</Code>
<Prompt><![CDATA[Blue]]></Prompt>
<DefaultOption>No</DefaultOption>
<Image>graphics/00000001/blueiamge.jpg</Image>
</ProductAttributeOption_Add>
<ProductAttributeOption_Add product_code="tshirt" attribute_code="color">
<Code>yellow</Code>
<Prompt><![CDATA[Yellow]]></Prompt>
<DefaultOption>No</DefaultOption>
<Image>graphics/00000001/yellowimage.jpg</Image>
</ProductAttributeOption_Add>
<!-- ==================== END MASTER ==================== -->
<!-- ==================== START VARIANT PARTS ==================== -->
<Product_Add>
<Code>tshirt-red-small</Code>
<!--
...
...
...
-->
<Active>No</Active>
</Product_Add>
<ProductImage_Add product_code="tshirt-red-small" filepath="graphics/00000001/redimage.jpg" type_code="main" />
<Product_Add>
<Code>tshirt-blue-small</Code>
<!--
...
...
...
-->
<Active>No</Active>
</Product_Add>
<ProductImage_Add product_code="tshirt-blue-small" filepath="graphics/00000001/blueimage.jpg" type_code="main" />
<!-- ==================== END VARIANT PARTS ==================== -->
<!-- ==================== START VARIANT MAPPING ==================== -->
<ProductVariant_Add product_code="tshirt">
<Options>
<Attribute_Option attribute_code="color" option_code="red" />
<Attribute_Option attribute_code="size" option_code="small" />
</Options>
<Parts>
<Part product_code="tshirt-red-small" quantity="1" />
</Parts>
<ProductVariantPricing>
<Method>sum</Method>
</ProductVariantPricing>
</ProductVariant_Add>
<ProductVariant_Add product_code="tshirt">
<Options>
<Attribute_Option attribute_code="color" option_code="blue" />
<Attribute_Option attribute_code="size" option_code="small" />
</Options>
<Parts>
<Part product_code="tshirt-blue-small" quantity="1" />
</Parts>
<ProductVariantPricing>
<Method>sum</Method>
</ProductVariantPricing>
</ProductVariant_Add>
<!-- ==================== END VARIANT MAPPING ==================== -->
<!--
This should result in the following:
1) A master product with code `tshirt` will be created. Should be active.
2) `tshirt` will have two attributes associated with it: `Size` & `Color`.
3) The `Size` attribute should have three options: `Small`(default), `Medium` & `Large`.
4) The `Color` attribute should have three options: `Red`(default), `Blue` & `Yellow`.
5) Two variant parts should be created `tshirt-red-small` & `tshirt-blue-small`. Both should be inactive.
6) Variant part `tshirt-red-small` should be mapped to `tshirt` via the `size:small` and `color:red` attribute:options.
7) Variant part `tshirt-blue-small` should be mapped to `tshirt` via the `size:small` and `color:blue` attribute:options.
8) The other attribute:option combinations were left unconfigured.
-->
@mghdotdev
Copy link
Author

Added lines <Image> node to attribute option tags on lines 57 & 63

Added <ProductImage_Add> tags to lines 77 & 88

@vivian-tran
Copy link

Thank you so much, Max

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment