WebSphere Commerce 7 | Custom Dataload | Catalog Entry Dataload | BOD Objects to Set in Custom Data Reader

If you are writing custom datareader for Catalog Entry Dataload, here is the sample snippet for different BOD Objects to set,

// Create object for partnumber
PartNumberIdentifierType partNumberIdentifierType = CommerceFoundationFactory.eINSTANCE.createPartNumberIdentifierType();
partNumberIdentifierType.setPartNumber("Reebok_765687");

CatalogEntryIdentifierType identifier = CommerceFoundationFactory.eINSTANCE.createCatalogEntryIdentifierType();
identifier.setExternalIdentifier(partNumberIdentifierType);
       
// Create object for parent catgroup

CatalogGroupExternalIdentifierType catGroupExternalIdentifierType = CommerceFoundationFactory.eINSTANCE.createCatalogGroupExternalIdentifierType();
catGroupExternalIdentifierType.setGroupIdentifier("reebokShoes");

CatalogGroupIdentifierType catGroupIdentifierType = CommerceFoundationFactory.eINSTANCE.createCatalogGroupIdentifierType();
catGroupIdentifierType.setExternalIdentifier(catGroupExternalIdentifierType);

// Create object for catalog description
CatalogDescriptionType catalogDescType = CatalogFactory.eINSTANCE.createCatalogDescriptionType();
catalogDescType.setLanguage("-1");
catalogDescType.setName("Reebok Express Fancy Shoes");
catalogDescType.setShortDescription("Reebok Express Fancy Shoes sold in India");
catalogDescType.setLongDescription("Reebok Express Fancy Shoes - For comfort and styling");
catalogDescType.getAttributes().put(AVAILABLE, "1");
catalogDescType.getAttributes().put(PUBLISHED, "1");       

// Create Catentry Attributes       
CatalogEntryAttributesType catalogEntryAttributesType = CatalogFactory.eINSTANCE.createCatalogEntryAttributesType();

// Manufacturer Partnumber

StringValueType stringMFPartNumberType = CatalogFactory.eINSTANCE.createStringValueType();
stringMFPartNumberType.setValue("reebokManufacturesIndia");
CatalogAttributeType catalogMFPartNumberAttrType = CatalogFactory.eINSTANCE.createCatalogAttributeType();
catalogMFPartNumberAttrType.setName("ManufacturerPartNumber");
catalogMFPartNumberAttrType.setStringValue(stringMFPartNumberType);
catalogEntryAttributesType.getAttributes().add(catalogMFPartNumberAttrType);
       
// Manufacturer Name

StringValueType stringMFNameType = CatalogFactory.eINSTANCE.createStringValueType();
stringMFNameType.setValue("Reebok Manufacturers India");
CatalogAttributeType catalogMFNameAttrType = CatalogFactory.eINSTANCE.createCatalogAttributeType();
catalogMFNameAttrType.setName("Manufacturer");
catalogMFNameAttrType.setStringValue(stringMFNameType);       
catalogEntryAttributesType.getAttributes().add(catalogMFNameAttrType);
       
// Buyable Flag
StringValueType stringBuyableValType = CatalogFactory.eINSTANCE.createStringValueType();
stringBuyableValType.setValue("1");
CatalogAttributeType catalogBuyableAttrType = CatalogFactory.eINSTANCE.createCatalogAttributeType();
catalogBuyableAttrType.setName("buyable");
catalogBuyableAttrType.setStringValue(stringBuyableValType);
catalogEntryAttributesType.getAttributes().add(catalogBuyableAttrType);       
// Create Basic Details of Catentry Object
CatalogEntryType catentry = CatalogFactory.eINSTANCE.createCatalogEntryType();

// Setting all the constructed objects to Catentry Object

catentry.setCatalogEntryIdentifier(catEntIdType);           
catentry.setParentCatalogGroupIdentifier(catalogGroupIdentifierType);
catentry.getDescription().add(catalogDescType);
catentry.setCatalogEntryAttributes(catalogAttributesType);
catentry.setCatalogEntryTypeCode("ProductBean");   

Set this prepared CatalogEntryType to DataLoadBusinessObject and return the same in next() method for the Custom Data Reader.

Refer WCS | Dataload Utility | Writing Custom Dataload link to know more details of custom data readers

No comments:

Post a Comment

My Writings........

HCL Commerce v9.1 | Local Store Vs Remote Store

  Local Store Remote Store Project Type Migrated (Lift & Shift) - Newly Imp...