Yup, my code is custom. Perhaps I was missing out on a service that was already available for this? Or what am I missing here?
As said: I tried to follow the ProductDemo.xml code, but couldn't get it all
right. If there is no such service available, are my steps correct that I
described above?
BJ Freeman wrote:
>
> This is problem in your code that is custom if I understand the email.
>
> I suggest you follow the code that does use it, in ofbiz, to compare
> what you are doing to what ofbiz does. and after that why not use the
> ofbiz code?
> you can start from the page that displays it and work backwards.
>
>
> madppiper sent the following on 5/19/2009 10:28 AM:
>> Hey everybody,
>>
>> I created a new product with locales and attributes just fine and wanted
>> to
>> add two new features/attributes to it: size & color. Just like in
>> WG-9943. I
>> am doing the following steps, but neither color nor size show up:
>>
>> 1) check if product with detailed information exists, if not create
>> 2) check if product is set to Virtual = Y, if not, edit and add Virtual
>> Variant Method = varianttree
>> 3) create a new product with id similar to originalproduct (eg:
>> productIdcolor) with Virtual = No, Variant = Y
>> 4) create ProductAssoc with createProductI18nRollup.productIdTo =
>> productIdColor, productId = productId, productAssocTypeId=
>> PRODUCT_VARIANT
>> 5) create ProductFeatureCategory if needed
>> 6) create ProductFeature with productFeatureTypeId = COLOR,
>> productFeatureId= FproductIdcolor
>> 7) create ProductFeatureAppl with productFeatureApplTypeId =
>> SELECTABLE_FEATURE & productId = productIdColor
>> 8) iterate through available sizes do
>> 8a) create ProductFeature with productFeatureTypeId=SIZE, productId=
>> productIdColor, productFeatureId=FproductIdColorSize
>> 8b) create ProductFeatureIactn with productFeatureIactnTypeId =
>> FEATURE_IACTN_INCOMP, productFeatureIdTo = FproductIdColor,
>> productFeatureId=FproductIdColorSize
>> 8c) create ProductFeatureAppl with productFeatureId= FproductIdColorSize,
>> productFeatureApplTypeId=STANDARD_FEATURE, productId= productIdColor
>> 8d) create ProductAssoc with productAssocTypeId= PRODUCT_VARIANT,
>> productIdTo= productIdColor, productId = product
>>
>>
>> As I do here:
>>
>>
>>
>>
>> <entity-and
>> entity-name="Product" list="resourceList">
>> <field-map
>> field-name="productId"
>> from-field="parameters.productId"/>
>> </entity-and>
>>
>> <first-from-list entry="resource"
>> list="resourceList"/>
>> <if-not-empty field="resource">
>>
>> <log
>> level="warning" message="Updating
>> ${parameters.productId}"></log>
>> <set
>> field="createProductI18nRollup.productId"
>> value="${parameters.productId}"/>
>> <set
>> field="createProductI18nRollup.isVirtual" value="Y"/>
>> <set
>> field="createProductI18nRollup.isVariant" value="N"/>
>> <set
>> field="createProductI18nRollup.virtualVariantMethodEnum"
>> value="VV_VARIANTTREE"/>
>>
>>
>>
>> <set-service-fields map="createProductI18nRollup"
>> service-name="editProductI18n" to-map="createProductI18nMap"/>
>>
>> <call-service
>> service-name="editProductI18n"
>> in-map-name="createProductI18nMap" break-on-error="true" />
>> </if-not-empty>
>>
>>
>> <call-bsh><![CDATA[
>> color = parameters.get("color");
>> if(color != null && color !=""){
>>
>> parameters.put("colorId", color.substring(0, 3).replace("
>> ","_"));
>> }
>> ]]></call-bsh>
>>
>>
>>
>> <!-- Create the
>> basic item -->
>>
>>
>> <map-to-map map="parameters" to-map="createProductI18nRollup"/>
>>
>> <set
>> field="createProductI18nRollup.taxable" value="Y"/>
>> <set
>> field="createProductI18nRollup.chargeShipping"
>> value="Y"/>
>> <set
>> field="createProductI18nRollup.isVirtual" value="N"/>
>> <set
>> field="createProductI18nRollup.isVariant" value="Y"/>
>>
>> <log
>> level="warning" message="COLORID : ${parameters.colorId}"/>
>> <set
>> field="createProductI18nRollup.productId"
>> value="${parameters.productId}${parameters.colorId}"/>
>> <set
>> field="createProductI18nRollup.productTypeId"
>> value="FINISHED_GOOD"/>
>>
>>
>>
>>
>> <set-service-fields map="createProductI18nRollup"
>> service-name="createProductI18n" to-map="createProductI18nMap"/>
>>
>>
>> <entity-and
>> entity-name="Product"
>> list="resourceList">
>> <field-map
>> field-name="productId"
>> from-field="createProductI18nRollup.productId"/>
>> </entity-and>
>>
>> <first-from-list
>> entry="resource"
>> list="resourceList"/>
>> <if-empty
>> field="resource">
>>
>>
>> <call-service service-name="createProductI18n"
>> in-map-name="createProductI18nMap"/>
>> <else>
>>
>> <call-service service-name="editProductI18n"
>> in-map-name="createProductI18nMap"/>
>> </else>
>>
>> </if-empty>
>>
>>
>> <!-- Create Assoc -->
>>
>>
>> <now-timestamp
>> field="createProductI18nRollup.fromDate"/>
>> <set
>> field="createProductI18nRollup.productIdTo"
>> value="${createProductI18nRollup.productId}"/>
>> <set
>> field="createProductI18nRollup.productId"
>> value="${parameters.productId}"/>
>> <set
>> field="createProductI18nRollup.productAssocTypeId"
>> value="PRODUCT_VARIANT"/>
>>
>>
>> <entity-and entity-name="ProductAssoc" list="resourceList">
>> <field-map
>> field-name="productId"
>> from-field="createProductI18nRollup.productId"/>
>> <field-map
>> field-name="productIdTo"
>> from-field="createProductI18nRollup.productIdTo"/>
>> <field-map
>> field-name="productAssocTypeId"
>> from-field="createProductI18nRollup.productAssocTypeId"/>
>> </entity-and>
>>
>> <first-from-list
>> entry="resource"
>> list="resourceList"/>
>> <if-empty
>> field="resource">
>>
>> <set-service-fields map="createProductI18nRollup"
>> service-name="createProductAssocI18n"
>> to-map="createProductFeatureCategoryI18nMap"/>
>>
>> <call-service service-name="createProductAssocI18n"
>> in-map-name="createProductFeatureCategoryI18nMap"/>
>> <else>
>>
>> <set field="createProductI18nRollup.fromDate"
>> value="${resource.fromDate}"/>
>>
>> <set-service-fields map="createProductI18nRollup"
>> service-name="editProductAssocI18n"
>> to-map="createProductFeatureCategoryI18nMap"/>
>>
>> <call-service service-name="editProductAssocI18n"
>> in-map-name="createProductFeatureCategoryI18nMap"/>
>> </else>
>>
>> </if-empty>
>>
>> <set
>> field="createProductI18nRollup.productId"
>> value="${createProductI18nRollup.productIdTo}"/>
>>
>>
>> <!-- Create the
>> ProductFeatureCategory if needed -->
>>
>> <set
>> field="createProductI18nRollup.productFeatureCategoryId"
>> value="BPfeatcat"/>
>> <set
>> field="createProductI18nRollup.description"
>> value="Brandsparadise Features"/>
>>
>> <entity-and
>> entity-name="ProductFeatureCategory"
>> list="resourceList">
>> <field-map
>> field-name="productFeatureCategoryId"
>> from-field="createProductI18nRollup.productFeatureCategoryId"/>
>> </entity-and>
>>
>> <first-from-list
>> entry="resource"
>> list="resourceList"/>
>> <if-empty
>> field="resource">
>>
>> <set-service-fields map="createProductI18nRollup"
>> service-name="createProductFeatureCategoryI18n"
>> to-map="createProductFeatureCategoryI18nMap"/>
>>
>> <call-service
>> service-name="createProductFeatureCategoryI18n"
>> in-map-name="createProductFeatureCategoryI18nMap"/>
>> <else>
>>
>> <set-service-fields map="createProductI18nRollup"
>> service-name="editProductFeatureCategoryI18n"
>> to-map="createProductFeatureCategoryI18nMap"/>
>>
>> <call-service service-name="editProductFeatureCategoryI18n"
>> in-map-name="createProductFeatureCategoryI18nMap"/>
>> </else>
>>
>> </if-empty>
>>
>>
>>
>> <!-- Create
>> Product Feature Color -->
>> <set
>> field="createProductI18nRollup.productFeatureTypeId"
>> value="COLOR"/>
>> <set
>> field="createProductI18nRollup.description"
>> value="${parameters.color}"/>
>> <set
>> field="createProductI18nRollup.productFeatureId"
>> value="F${parameters.productId}${parameters.colorId}"/>
>>
>>
>> <entity-and
>> entity-name="ProductFeature"
>> list="resourceList">
>> <field-map
>> field-name="productFeatureId"
>> from-field="createProductI18nRollup.productFeatureId"/>
>> </entity-and>
>>
>> <first-from-list
>> entry="resource"
>> list="resourceList"/>
>> <if-empty
>> field="resource">
>>
>> <set-service-fields map="createProductI18nRollup"
>> service-name="createProductFeatureI18n"
>> to-map="createProductFeatureI18nMap"/>
>>
>> <call-service service-name="createProductFeatureI18n"
>> in-map-name="createProductFeatureI18nMap"/>
>> <else>
>>
>> <set-service-fields map="createProductI18nRollup"
>> service-name="editProductFeatureI18n"
>> to-map="createProductFeatureI18nMap"/>
>>
>> <call-service service-name="editProductFeatureI18n"
>> in-map-name="createProductFeatureI18nMap"/>
>> </else>
>>
>> </if-empty>
>>
>>
>>
>> <!-- Create
>> Product Feature Appl -->
>>
>>
>> <set field="createProductI18nRollup.productFeatureApplTypeId"
>> value="SELECTABLE_FEATURE"/>
>>
>>
>>
>> <entity-and entity-name="ProductFeatureAppl"
>> list="resourceList">
>>
>> <field-map field-name="productId"
>> from-field="createProductI18nRollup.productId"/>
>> <field-map
>> field-name="productFeatureId"
>> from-field="createProductI18nRollup.productFeatureId"/>
>> <field-map
>> field-name="productFeatureApplTypeId"
>> from-field="createProductI18nRollup.productFeatureApplTypeId"/>
>> </entity-and>
>>
>>
>> <first-from-list entry="resource"
>> list="resourceList"/>
>> <if-empty
>> field="resource">
>>
>> <set-service-fields map="createProductI18nRollup"
>> service-name="createProductFeatureApplI18n"
>> to-map="createProductFeatureI18nMap"/>
>>
>> <call-service
>> service-name="createProductFeatureApplI18n"
>> in-map-name="createProductFeatureI18nMap"/>
>>
>> <else>
>>
>> <set-service-fields map="createProductI18nRollup"
>> service-name="editProductFeatureApplI18n"
>> to-map="createProductFeatureI18nMap"/>
>>
>> <call-service service-name="editProductFeatureApplI18n"
>> in-map-name="createProductFeatureI18nMap"/>
>>
>> </else>
>>
>> </if-empty>
>>
>>
>> <set field="newMap.colorId" from-field="parameters.colorId"/>
>>
>> <!-- Create
>> Product Feature Size -->
>>
>> <iterate
>> entry="size" list="parameters.size" >
>>
>>
>> <call-bsh><![CDATA[
>> color =
>> parameters.get("color");
>> if(color !=
>> null && color !=""){
>>
>>
>> parameters.put("colorId", color.substring(0,
>> 3).replace(" ","_"));
>> }
>> ]]></call-bsh>
>>
>> <set
>> field="createProductI18nRollup.productId"
>> value="${parameters.productId}${newMap.colorId}"/>
>> <set
>> field="createProductI18nRollup.productFeatureTypeId"
>> value="SIZE"/>
>> <set
>> field="createProductI18nRollup.description"
>> value="${size}"/>
>> <set
>> field="createProductI18nRollup.productFeatureId"
>> value="F${parameters.productId}${parameters.colorId}${size}"/>
>>
>>
>> <entity-and
>> entity-name="ProductFeature"
>> list="resourceList">
>> <field-map
>> field-name="productFeatureId"
>> from-field="createProductI18nRollup.productFeatureId"/>
>> </entity-and>
>>
>> <first-from-list
>> entry="resource"
>> list="resourceList"/>
>> <if-empty
>> field="resource">
>>
>> <set-service-fields map="createProductI18nRollup"
>> service-name="createProductFeatureI18n"
>> to-map="createProductFeatureI18nMap"/>
>>
>> <call-service service-name="createProductFeatureI18n"
>> in-map-name="createProductFeatureI18nMap"/>
>> <else>
>>
>> <set-service-fields map="createProductI18nRollup"
>> service-name="editProductFeatureI18n"
>> to-map="createProductFeatureI18nMap"/>
>>
>> <call-service service-name="editProductFeatureI18n"
>> in-map-name="createProductFeatureI18nMap"/>
>> </else>
>>
>> </if-empty>
>>
>>
>>
>>
>> <log
>> level="warning" message="createProductI18nRollup.productId
>> is
>> now ${createProductI18nRollup.productId}"></log>
>>
>>
>>
>> <!-- Link to color -->
>>
>>
>>
>> <set field="createProductI18nRollup.productFeatureIdTo"
>> value="F${parameters.productId}${parameters.colorId}"/>
>>
>> <set
>> field="createProductI18nRollup.productFeatureIactnTypeId"
>> value="FEATURE_IACTN_INCOMP"/>
>>
>> <set field="createProductI18nRollup.productFeatureId"
>> value="F${parameters.productId}${parameters.colorId}${size}"/>
>>
>> <entity-and entity-name="ProductFeatureIactn"
>> list="resourceList">
>>
>> <field-map field-name="productFeatureId"
>> from-field="createProductI18nRollup.productFeatureId"/>
>>
>> <field-map field-name="productFeatureIdTo"
>> from-field="createProductI18nRollup.productFeatureIdTo"/>
>>
>> </entity-and>
>>
>>
>>
>> <first-from-list entry="resource"
>> list="resourceList"/>
>>
>> <if-empty field="resource">
>>
>>
>> <now-timestamp
>> field="createProductI18nRollup.fromDate"/>
>>
>> <set field="createProductI18nRollup.productId"
>> value="${createProductI18nRollup.productId}"/>
>>
>> <set-service-fields map="createProductI18nRollup"
>> service-name="createProductFeatureIactnI18n"
>> to-map="createProductFeatureI18nMap"/>
>>
>> <call-service
>> service-name="createProductFeatureIactnI18n"
>> in-map-name="createProductFeatureI18nMap"/>
>>
>> <else>
>>
>> <!--
>>
>> <set field="createProductI18nRollup.productFeatureId"
>> value="${resource.productFeatureId}"/>
>>
>> <set field="createProductI18nRollup.productFeatureIdTo"
>> value="${resource.productFeatureIdTo}"/>
>>
>>
>>
>> <set-service-fields map="createProductI18nRollup"
>> service-name="editProductFeatureIactnI18n"
>> to-map="createProductFeatureI18nMap"/>
>>
>> <call-service
>> service-name="editProductFeatureIactnI18n"
>> in-map-name="createProductFeatureI18nMap"/> -->
>>
>> </else>
>>
>> </if-empty>
>>
>>
>> <log
>> level="warning" message="createProductI18nRollup.productId
>> is
>> now ${createProductI18nRollup.productId}"></log>
>>
>>
>>
>> <!-- Product Feature Appl -->
>>
>>
>>
>> <set
>> field="createProductI18nRollup.productFeatureApplTypeId"
>> value="STANDARD_FEATURE"/>
>>
>> <now-timestamp
>> field="createProductI18nRollup.fromDate"/>
>>
>>
>> <entity-and entity-name="ProductFeatureAppl"
>> list="resourceList">
>>
>> <field-map field-name="productId"
>> from-field="createProductI18nRollup.productId"/>
>>
>> <field-map field-name="productFeatureId"
>> from-field="createProductI18nRollup.productFeatureId"/>
>>
>> </entity-and>
>>
>>
>>
>> <first-from-list entry="resource"
>> list="resourceList"/>
>>
>> <if-empty field="resource">
>>
>> <set-service-fields
>> map="createProductI18nRollup"
>> service-name="createProductFeatureApplI18n"
>> to-map="createProductFeatureI18nMap"/>
>>
>> <call-service
>> service-name="createProductFeatureApplI18n"
>> in-map-name="createProductFeatureI18nMap"/>
>>
>> <else>
>>
>> <set field="createProductI18nRollup.fromDate"
>> value="${resource.fromDate}"/>
>>
>>
>>
>> <set-service-fields map="createProductI18nRollup"
>> service-name="editProductFeatureApplI18n"
>> to-map="createProductFeatureI18nMap"/>
>>
>> <call-service
>> service-name="editProductFeatureApplI18n"
>> in-map-name="createProductFeatureI18nMap"/>
>>
>> </else>
>>
>> </if-empty>
>>
>>
>> <log
>> level="warning" message="createProductI18nRollup.productId
>> is
>> now ${createProductI18nRollup.productId}"></log>
>>
>>
>> <!-- Create Assoc -->
>>
>>
>>
>> <now-timestamp
>> field="createProductI18nRollup.fromDate"/>
>>
>> <set
>> field="createProductI18nRollup.productIdTo"
>> value="${createProductI18nRollup.productId}"/>
>>
>> <set
>> field="createProductI18nRollup.productId"
>> value="${parameters.productId}"/>
>>
>> <set
>> field="createProductI18nRollup.productAssocTypeId"
>> value="PRODUCT_VARIANT"/>
>>
>> <log level="warning" message="Adding
>> ProductAssoc for
>> Product_Variant ${createProductI18nRollup.productId} to
>> ${createProductI18nRollup.productIdTo}"></log>
>>
>> <entity-and
>> entity-name="ProductAssoc"
>> list="resourceList">
>>
>> <field-map field-name="productId"
>> from-field="createProductI18nRollup.productId"/>
>>
>> <field-map field-name="productIdTo"
>> from-field="createProductI18nRollup.productIdTo"/>
>>
>> <field-map
>> field-name="productAssocTypeId"
>> from-field="createProductI18nRollup.productAssocTypeId"/>
>>
>> </entity-and>
>>
>>
>>
>> <first-from-list entry="resource"
>> list="resourceList"/>
>>
>> <if-empty field="resource">
>>
>> <set-service-fields
>> map="createProductI18nRollup"
>> service-name="createProductAssocI18n"
>> to-map="createProductFeatureCategoryI18nMap"/>
>>
>> <call-service
>> service-name="createProductAssocI18n"
>> in-map-name="createProductFeatureCategoryI18nMap"/>
>>
>> <else>
>>
>> <set
>> field="createProductI18nRollup.fromDate"
>> value="${resource.fromDate}"/>
>>
>> <set-service-fields
>> map="createProductI18nRollup"
>> service-name="editProductAssocI18n"
>> to-map="createProductFeatureCategoryI18nMap"/>
>>
>> <call-service
>> service-name="editProductAssocI18n"
>> in-map-name="createProductFeatureCategoryI18nMap"/>
>>
>> </else>
>>
>> </if-empty>
>>
>>
>>
>> <set field="createProductI18nRollup.productId"
>> value="${createProductI18nRollup.productIdTo}"/>
>>
>>
>>
>> </iterate>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> I tried to follow the steps for WG-9943 in ProductDemo.xml carefully, but
>> the variants won't show up on my application. What am I missing?
>
> --
> BJ Freeman
> http://www.businessesnetwork.com/automation
> http://bjfreeman.elance.com
> http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro
> Systems Integrator.
>
>
>
--
View this message in context:
http://www.nabble.com/Confused-over-Size---Color-tp23620869p23629680.html
Sent from the OFBiz - User mailing list archive at Nabble.com.
