Вы находитесь на странице: 1из 29

Step to follow for Multicountry

Update Data and New


Syncronization
Version: 1.0.0
Date: 17/04/2014

CONFIDENTIAL

June 24st, 2014

Page 1

Table of Contents
1

Introduction............................................................................................................................3

Catalog Structure and syncronization....................................................................................4

Steps......................................................................................................................................6

CONFIDENTIAL

June 24st, 2014

Page 2

Introduction
The goal of this documents its introduce the new catalog structure multicountry in the
current system mono-country and add the new jobs of synchronization.
In order to create differents cases test has been created step impex to launch in local
environment.
Before lets show the entire new catalog structure, with focalization on job used for the
new flows of synchronization, and after the step to follow to ensure correct
functionality of new synchronization.

CONFIDENTIAL

June 24st, 2014

Page 3

Catalog
Structure and
syncronization
This is the catalog structure with all the jobs syncronization:

Figura 1

CONFIDENTIAL

June 24st, 2014

Page 4

Figura 2

CONFIDENTIAL

June 24st, 2014

Page 5

Steps
The necessary step to realize data-migration are:
1) Turn off of all Hybris node Commerce.
2) Update with only hmwebservice checked

3) Stop the job related to R1, with this impex:


INSERT_UPDATE CronJob;code[unique=true];active; retry
;changeOrderStatusCronJob;false;false
;consignmentManagerJob;false;false
;orderToSAPExportJob;false;false
;fullCustomerExportCronJob;false;false
;imagesImportCronJob;false;false
;importCatalogCronJob;false;false
;orderBlindReturnsImportJob;false;false
;orderHistoryExportJob;false;false
;stockAdjustmentDataLoaderCronJob;false;false
;stockDailySnapshotCronJob;false;false
;stockLevelDataLoaderCronJob;false;false
;subscriberUserExporterJob;false;false
;stockAdjustmentDataLoaderCronJob;false; false
;Cluster 0: Lucenesearch-RebuildIndex-Job;false; false;
;Cluster 0: Lucenesearch-UpdateIndex-Job; false; false;
;subscriberUserExporterJob; false; false
;imagesImportCronJob; false; false
;fullCustomerExportCronJob; false; false
;orderHistoryExportJob; false; false
;stockDailySnapshotCronJob; false; false

CONFIDENTIAL

June 24st, 2014

Page 6

;importCatalogCronJob; false; false

4) Build of last release, from Jenkins interface;


5) Check for property is migration that must be setted to true. In HAC
->Console->Configuration, search the name of property:

If it is setted to false set it to true.

6) Rename of Catalog from hm-franceProductCatalog to hmeuropeProductCatalog

CONFIDENTIAL

June 24st, 2014

Page 7

7) Change the iso_code of language Spanish from es to es_ES:


Open the Administration tab

CONFIDENTIAL

June 24st, 2014

Page 8

Go down to the Language section and right- click to open the language
window

Change the value of ISO Code from es to es_ES.

Save and Close the window.


8) (if a restart has occurred before this step, then you need to recheck the
is.migration property, because the restart of server hybris set this property to
false but during the migration it must be set to true). Update with only first 4
check, multicountry, hmcore(with yes selection for sync Product and Content
Catalogs and yes for Import China Provinces and Import Size Filter Orders) ,
hminterfaces and hmcockpits

CONFIDENTIAL

June 24st, 2014

Page 9

CONFIDENTIAL

June 24st, 2014

Page 10

9) Update with only create essentialdata

10)

Stop all job with launch of this impex form HAC ->Console->Impex Import:

INSERT_UPDATE CronJob;code[unique=true];active;retry
;full-hm-franceProductOOBIndex-cronJob;false;false
;full-hm-franceCategoryIndex-cronJob;false;false
;full-hm-franceProductHMIndex-cronJob;false;false
;update-hm-franceCategoryIndex-cronJob;false;false
;update-hm-franceProductHMIndex-cronJob;false;false
;update-hm-franceProductOOBIndex-cronJob;false;false
;full-hm-italyProductOOBIndex-cronJob;false;false
;full-hm-italyCategoryIndex-cronJob;false;false
;full-hm-italyProductHMIndex-cronJob;false;false
;update-hm-italyCategoryIndex-cronJob;false;false
;update-hm-italyProductHMIndex-cronJob;false;false
;update-hm-italyProductOOBIndex-cronJob;false;false
;full-hm-spainProductOOBIndex-cronJob;false;false

CONFIDENTIAL

June 24st, 2014

Page 11

;full-hm-spainCategoryIndex-cronJob;false;false
;full-hm-spainProductHMIndex-cronJob;false;false
;update-hm-spainCategoryIndex-cronJob;false;false
;update-hm-spainProductHMIndex-cronJob;false;false
;update-hm-spainProductOOBIndex-cronJob;false;false
;full-hm-portugalProductOOBIndex-cronJob;false;false
;full-hm-portugalCategoryIndex-cronJob;false;false
;full-hm-portugalProductHMIndex-cronJob;false;false
;update-hm-portugalCategoryIndex-cronJob;false;false
;update-hm-portugalProductHMIndex-cronJob;false;false
;update-hm-portugalProductOOBIndex-cronJob;false;false
;full-hm-chinaProductOOBIndex-cronJob;false;false
;full-hm-chinaCategoryIndex-cronJob;false;false
;full-hm-chinaProductHMIndex-cronJob;false;false
;update-hm-chinaCategoryIndex-cronJob;false;false
;update-hm-chinaProductHMIndex-cronJob;false;false
;update-hm-chinaProductOOBIndex-cronJob;false;false
;paymentProcessCronJob;false;false
INSERT_UPDATE MulticountryCronJob;code[unique=true];active;retry
;asiaChangeOrderStatusCronJob;false;false
;europeChangeOrderStatusCronJob;false;false
;asiaOrderBlindReturnsImportJob;false;false
;europeOrderBlindReturnsImportJob;false;false
;europeOrderToSAPExportJob;false;false
;europeConsignmentExportJob;false;false
;asiaConsignmentExportJob;false;false
;asiaStockAdjustmentDataLoaderCronJob;false;false
;europeStockAdjustmentDataLoaderCronJob;false;false
INSERT_UPDATE CronJob;code[unique=true];active;retry
#;stockAdjustmentDataLoaderCronJob;false;false
;Cluster 0: Lucenesearch-RebuildIndex-Job;false;false
;Cluster 0: Lucenesearch-UpdateIndex-Job;false;false
;subscriberUserExporterJob;false;false
;imagesImportCronJob;false;false
;fullCustomerExportCronJob;false;false
;orderHistoryExportJob;false;false
;stockDailySnapshotCronJob;false;false
;importCatalogCronJob;false;false
;orderSettlementJob;false;false
;consignmentCreationJob;false;false
;pendingPaymentCheckCronJob;false;false

CONFIDENTIAL

June 24st, 2014

Page 12

11)
Reclamation of data for france-store to adapt them with new structure
multicountry
a. Launch of Beanshell PriceRow Reclamation (for france) from HAC>Console->BeanShell(whit commit activated):
import
import
import
import
import
import
import
import
import
import
import
import
import
import

goep.hm.multicountry.model.productavailabilitygroup.ProductAvailabilityGroupModel;
java.util.Collection;
org.apache.log4j.Logger;
de.hybris.platform.catalog.CatalogVersionService;
de.hybris.platform.catalog.model.CatalogVersionModel;
de.hybris.platform.core.Registry;
de.hybris.platform.europe1.enums.UserPriceGroup;
de.hybris.platform.europe1.model.PriceRowModel;
de.hybris.platform.servicelayer.model.ModelService;
de.hybris.platform.servicelayer.search.FlexibleSearchQuery;
de.hybris.platform.servicelayer.search.FlexibleSearchService;
de.hybris.platform.servicelayer.search.SearchResult;
de.hybris.platform.store.services.BaseStoreService;
goep.hm.multicountry.services.MulticountryRestrictionService;

Logger log = Logger.getLogger( "BeanShellpriceRowReclamation" );


log.info("STARTED BeanShellpriceRowReclamation");
FlexibleSearchService flexibleSearchService = (FlexibleSearchService)
Registry.getApplicationContext().getBean("flexibleSearchService");
CatalogVersionService catalogVersionService = (CatalogVersionService)
Registry.getApplicationContext().getBean("catalogVersionService");
BaseStoreService baseStoreService = (BaseStoreService)
Registry.getApplicationContext().getBean("baseStoreService");
MulticountryRestrictionService multicountryRestrictionService = (MulticountryRestrictionService)
Registry.getApplicationContext().getBean("multicountryRestrictionService");
ModelService modelService = (ModelService)
Registry.getApplicationContext().getBean("modelService");
CatalogVersionModel cv = catalogVersionService.getCatalogVersion("hm-europeProductCatalog",
"Staged");
catalogVersionService.setSessionCatalogVersion("hm-europeProductCatalog", "Staged");
// Get and save the availability groups for the current base store
Collection availabilityGroups = baseStoreService.getBaseStoreForUid("hmfrance").getAvailabilityGroups();
multicountryRestrictionService.setCurrentProductAvailabilityGroups(availabilityGroups);
FlexibleSearchQuery priceRowQuery = new FlexibleSearchQuery("Select {upg.pk} from {PriceRow
as upg} where {catalogVersion} =?catalogVersion");
priceRowQuery.addQueryParameter("catalogVersion", cv);
SearchResult priceRowResult = flexibleSearchService.search(priceRowQuery);
UserPriceGroup upgfrance = UserPriceGroup.valueOf("pricegroup-fr");
Integer counter = Integer.valueOf(0);
Integer counterExceptions = Integer.valueOf(0);
System.out.println("Prepare to Save : " + priceRowResult.getResult().size() + " prices");
log.info("Prepare to UPDATE: "+priceRowResult.getResult().size() + " prices");
for (Object obj : priceRowResult.getResult()) {
PriceRowModel pg = (PriceRowModel) obj;
try {
pg.setUg(upgfrance);
modelService.save(pg);
counter++;
} catch (Exception e) {
log.info("Exception for product "+pg.getProduct().getCode() +": "+ e.getMessage());
counterExceptions++;
}
}
log.info("PriceRows UPDATED: "+counter);
log.info("PriceRows Exception: "+counterExceptions);
log.info("FINISHED BeanShellpriceRowReclamation");

CONFIDENTIAL

June 24st, 2014

Page 13

And check the log for monitoring.


b. Launch of Beanshell for Copy WhitePrice of France in other Europe
countries:
/*****************************
//BeanShellCreateEuropePriceRow
********************/
import org.apache.log4j.Logger;
import de.hybris.platform.catalog.CatalogVersionService;
import de.hybris.platform.catalog.model.CatalogVersionModel;
import de.hybris.platform.core.Registry;
import de.hybris.platform.europe1.enums.UserPriceGroup;
import de.hybris.platform.europe1.model.PriceRowModel;
import de.hybris.platform.servicelayer.model.ModelService;
import de.hybris.platform.servicelayer.search.FlexibleSearchQuery;
import de.hybris.platform.servicelayer.search.FlexibleSearchService;
import de.hybris.platform.servicelayer.search.SearchResult;
import de.hybris.platform.store.services.BaseStoreService;
import goep.hm.multicountry.services.MulticountryRestrictionService;
import de.hybris.platform.core.model.product.ProductModel;

Logger log = Logger.getLogger( " BeanShellCreateEuropeWhitePriceRow" );


log.info("STARTED BeanShellCreateEuropePriceRow");
FlexibleSearchService flexibleSearchService = (FlexibleSearchService)
Registry.getApplicationContext().getBean("flexibleSearchService");
CatalogVersionService catalogVersionService = (CatalogVersionService)
Registry.getApplicationContext().getBean("catalogVersionService");
BaseStoreService baseStoreService = (BaseStoreService)
Registry.getApplicationContext().getBean("baseStoreService");
MulticountryRestrictionService multicountryRestrictionService =
(MulticountryRestrictionService)
Registry.getApplicationContext().getBean("multicountryRestrictionService");
ModelService modelService = (ModelService)
Registry.getApplicationContext().getBean("modelService");
CatalogVersionModel cv = catalogVersionService.getCatalogVersion("hmeuropeProductCatalog", "Staged");
UserPriceGroup upg = UserPriceGroup.valueOf("pricegroup-fr");
UserPriceGroup upgIt = UserPriceGroup.valueOf("pricegroup-it");
UserPriceGroup upgEs = UserPriceGroup.valueOf("pricegroup-es");
catalogVersionService.setSessionCatalogVersion("hm-europeProductCatalog", "Staged");
Integer counterExceptions = Integer.valueOf(0);
Integer counterExceptionsFOR = Integer.valueOf(0);
Integer counterIt = Integer.valueOf(0);
Integer counterEs = Integer.valueOf(0);
Integer totalResultQuery = Integer.valueOf(0);
Double totalPercentage = Double.valueOf(0);
Integer totalCounter = Integer.valueOf(0);
//retrieve the collection of all product with PR French
FlexibleSearchQuery productWithPriceRowQuery = new
FlexibleSearchQuery("select DISTINCT {pr.product} from {PriceRow as pr} where
{pr.catalogVersion}=?catalogVersion and {pr.ug}=?upgfrance");
productWithPriceRowQuery.addQueryParameter("catalogVersion", cv);
productWithPriceRowQuery.addQueryParameter("upgfrance", upg);
SearchResult productWithPriceRowResult =
flexibleSearchService.search(productWithPriceRowQuery);

CONFIDENTIAL

June 24st, 2014

Page 14

log.info("Prepare to SCAN: "+productWithPriceRowResult.getResult().size() + "


products");

totalResultQuery = productWithPriceRowResult.getResult().size();
Integer currentPercentage= Integer.valueOf(0);
for (Object obj : productWithPriceRowResult.getResult()) {
totalCounter++;
ProductModel p = (ProductModel) obj;
try {
//Set white price
if(p.getWhitePrice()!= null){
//log.info("TEST p.getWhitePrice():

"+p.getWhitePrice().getPrice());

PriceRowModel currentPR= p.getWhitePrice();


//IT
PriceRowModel newItPR =

modelService.clone(currentPR);

newItPR.setUg(upgIt);
modelService.save(newItPR);
counterIt++;
//ES
PriceRowModel newEsPR =

modelService.clone(currentPR);

newEsPR.setUg(upgEs);
modelService.save(newEsPR);
counterEs++;
}
} catch (Exception e) {
log.info("Exception for product " +p.getCode()+";

"+e.getMessage());

counterExceptions++;
}
totalPercentage = ( Double.valueOf(totalCounter) /
Double.valueOf(totalResultQuery))* 100;
if(currentPercentage<totalPercentage.intValue()){
currentPercentage=totalPercentage.intValue();
log.info("Progress: "+totalPercentage.intValue()+"% --"+totalCounter+" Products of "+totalResultQuery+" total Products scanned");
}

}
log.info("PriceRows IT correctly created: "+counterIt);
log.info("PriceRows ES correctly created: "+counterEs);
log.info("Exception encountered: "+counterExceptions);
log.info("BeanShellCreateEuropeWhitePriceRow FINISHED");
System.out.println("Exception encountered: "+counterExceptions);
System.out.println("PriceRows IT correctly created: "+counterIt);
System.out.println("PriceRows ES correctly created: "+counterEs);
System.out.println("BeanShellCreateEuropeWhitePriceRow FINISHED");

And check the log for monitoring.

CONFIDENTIAL

June 24st, 2014

Page 15

And check the log for monitoring.


c. Launch Beanshell PAA(for france) from HAC->Console->BeanShell(whit
commit activated):
import goep.hm.core.model.HMArticleModel;
import
goep.hm.multicountry.model.productavailabilitygroup.ProductAvailabilityAssignmentModel;
import goep.hm.multicountry.model.productavailabilitygroup.ProductAvailabilityGroupModel;
import goep.hm.multicountry.services.MulticountryRestrictionService;
import de.hybris.platform.store.services.BaseStoreService;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.log4j.Logger;
import de.hybris.platform.catalog.CatalogVersionService;
import de.hybris.platform.catalog.model.CatalogVersionModel;
import de.hybris.platform.core.Registry;
import de.hybris.platform.europe1.enums.UserPriceGroup;
import de.hybris.platform.europe1.enums.UserTaxGroup;
import de.hybris.platform.europe1.model.PriceRowModel;
import de.hybris.platform.europe1.model.TaxRowModel;
import de.hybris.platform.servicelayer.model.ModelService;
import de.hybris.platform.servicelayer.search.FlexibleSearchQuery;
import de.hybris.platform.servicelayer.search.FlexibleSearchService;
import de.hybris.platform.servicelayer.search.SearchResult;
import de.hybris.platform.store.BaseStoreModel;
import de.hybris.platform.servicelayer.user.UserService;
Logger log = Logger.getLogger( "BeanShellPAAReclamation" );
log.info("STARTED BeanShellPAAReclamation");
System.out.println("STARTED BeanShellPAAReclamation");
UserService userService =
(UserService)Registry.getApplicationContext().getBean("userService");
userService.setCurrentUser(userService.getAdminUser());
FlexibleSearchService flexibleSearchService = (FlexibleSearchService)
Registry.getApplicationContext().getBean("flexibleSearchService");
CatalogVersionService catalogVersionService = (CatalogVersionService)
Registry.getApplicationContext().getBean("catalogVersionService");
BaseStoreService baseStoreService = (BaseStoreService)
Registry.getApplicationContext().getBean("baseStoreService");
MulticountryRestrictionService multicountryRestrictionService =
(MulticountryRestrictionService)
Registry.getApplicationContext().getBean("multicountryRestrictionService");
ModelService modelService = (ModelService)
Registry.getApplicationContext().getBean("modelService");
CatalogVersionModel cv = catalogVersionService.getCatalogVersion("hmeuropeProductCatalog", "Staged");
catalogVersionService.setSessionCatalogVersion("hm-europeProductCatalog",
"Staged");
// Get and save the availability groups for the current base store
Collection availabilityGroups = baseStoreService.getBaseStoreForUid("hmfrance").getAvailabilityGroups();
multicountryRestrictionService.setCurrentProductAvailabilityGroups(availabilityGroups);

CONFIDENTIAL

June 24st, 2014

Page 16

System.out.println("Prepare to Start queries");


log.info("Prepare to Start queries");
FlexibleSearchQuery articleQuery = new FlexibleSearchQuery("Select {pk} from
{HMArticle!} where {catalogVersion} =?catalogVersion");
articleQuery.addQueryParameter("catalogVersion", cv);
SearchResult articleResult = flexibleSearchService.search(articleQuery);
FlexibleSearchQuery storeQuery = new FlexibleSearchQuery("Select {pk} from
{BaseStore} where {uid} in ('hm-france')");
SearchResult storeResult = flexibleSearchService.search(storeQuery);
List markets = new ArrayList();
// Market target
for (Object obj : storeResult.getResult()) {
markets.add((BaseStoreModel) obj);
}
System.out.println("Prepare to create : "+articleResult.getResult().size()+" PAA ");
log.info("Prepare to create : "+articleResult.getResult().size()+" PAA ");
Integer counterPAAAlreadyPresent = Integer.valueOf(0);
Integer counter = Integer.valueOf(0);
Integer counterExceptions = Integer.valueOf(0);
for (Object obj : articleResult.getResult()) {
HMArticleModel article = (HMArticleModel) obj;
//Product Avaibility Group Assignment gi esistenti
Collection articleAvalabilities = article.getAvailability();
Collection selectedArticleGroups = new ArrayList();
for (Object bsObj : markets) {
BaseStoreModel bs = (BaseStoreModel) bsObj;
selectedArticleGroups.addAll(bs.getAvailabilityGroups());
}
//Create new ProductAvailabilityAssignment
for (Object productAvailabityGroupObj : selectedArticleGroups) {
try{
ProductAvailabilityGroupModel group =
(ProductAvailabilityGroupModel) productAvailabityGroupObj;
ProductAvailabilityAssignmentModel found = null;
ProductAvailabilityAssignmentModel newPAA =
modelService.create(ProductAvailabilityAssignmentModel.class);
newPAA.setCatalogVersion(article.getCatalogVersion());
newPAA.setProduct(article);
newPAA.setOnlineDate(article.getOnlineDate());
newPAA.setOfflineDate(article.getOfflineDate());
newPAA.setStatus(article.getApprovalStatus());
newPAA.setAvailabilityGroup(group);
try{
found =
flexibleSearchService.getModelByExample(newPAA);
}catch(Exception e){
//not PAA already present
}
if (found == null) {
modelService.save(newPAA);
counter++;
}else{
counterPAAAlreadyPresent++;
}
} catch (Exception e) {
counterExceptions++;
log.info("Exception for article
"+article.getCode() +": "+ e.getMessage());
}
}
}
log.info("FINISHED BeanShellPAAReclamation, "+"PAA created : "+counter+", PAA already
present: "+counterPAAAlreadyPresent+", Exceptions: "+counterExceptions);
System.out.println("FINISHED BeanShellPAAReclamation, "+"PAA created : "+counter+", PAA
already present: "+counterPAAAlreadyPresent+", Exceptions: "+counterExceptions);

CONFIDENTIAL

June 24st, 2014

Page 17

And check the log for monitoring.


d. Launch of query to update old customer with French Store from HAC>FlexibleSearch and tab SQL Query:

UPDATE users SET users.p_store = (SELECT basestore.pk FROM basestore WHERE


basestore.p_uid='hm-france') WHERE users.p_store IS NULL AND users.TypePkString = (SELECT pk
FROM composedtypes WHERE internalcodelowercase='customer')

e. Launch of query to update old orders without merchantreferencecode:


update orders set p_merchantreferencecode = code where p_merchantreferencecode is null

12)
Launch of Synchronization from Europe to Master (J1 in figura 1 above)
From HMC -> Catalog->Catalog Management Tools-Syncronization:

Select hm-europeProduct and click on next. Then select J1 one shot record and
start:

CONFIDENTIAL

June 24st, 2014

Page 18

13)
Launch of beanshell to remove the relation between catalogs Master and
Europe, from HAC->Console->BeanShell(launch it with 50000 batchSize at a
time):
import de.hybris.platform.jalo.user.UserManager;
import de.hybris.platform.jalo.user.User;
import de.hybris.platform.jalo.JaloSession;
import de.hybris.platform.core.Registry;
import de.hybris.platform.catalog.model.ItemSyncTimestampModel;
import de.hybris.platform.servicelayer.search.FlexibleSearchService;
import de.hybris.platform.servicelayer.search.FlexibleSearchQuery;
import de.hybris.platform.servicelayer.search.SearchResult;
import de.hybris.platform.servicelayer.model.ModelService;
import java.util.List;
import org.apache.log4j.Logger;
/*************************************************
* SCRIPT VARIABLES
*
*************************************************/
Logger log = Logger.getLogger( " BeanShellRemoveRelation" );
String sourceCatalog = "hm-europeProductCatalog";
String sourceCatalogVersion = "Staged";
String targetCatalog = "hm-masterProductCatalog";
String targetCatalogVersion = "Staged";
int startCounter = 0;
int batchSize = 50000;
/*************************************************
* SCRIPT SERVICES
*
*************************************************/
FlexibleSearchService fss =
(FlexibleSearchService)Registry.getApplicationContext().getBean("flexibleSearchService");
ModelService ms = (ModelService)Registry.getApplicationContext().getBean("modelService");
/*************************************************
* SCRIPT BODY
*
*************************************************/
log.info("STARTED BeanShellRemoveRelation");
out.println("#BeanShell now is executed with user rights:" + JaloSession.getCurrentSession().getUser());
log.info("#BeanShell now is executed with user rights:" + JaloSession.getCurrentSession().getUser());
User previousUser = JaloSession.getCurrentSession().getUser();
JaloSession.getCurrentSession().setUser(UserManager.getInstance().getAdminEmployee());
out.println("fetching orphaned ItemSyncTimeStamp(s)");
log.info("fetching orphaned ItemSyncTimeStamp(s)");
/*
* The aim of the query is to extract all the ItemSyncTimestamps that has the wrong
* catalog set as source
*/
String query = " SELECT {ist.pk} FROM {ItemSyncTimestamp AS ist JOIN CatalogVersion AS
sourceCatalogVersion ON {ist.sourceVersion}={sourceCatalogVersion.pk} JOIN CatalogVersion AS
targetCatalogVersion ON {ist.targetVersion}={targetCatalogVersion.pk} JOIN Catalog AS sourceCatalog ON

CONFIDENTIAL

June 24st, 2014

Page 19

{sourceCatalogVersion.catalog}={sourceCatalog.pk} JOIN Catalog AS targetCatalog ON


{targetCatalogVersion.catalog}={targetCatalog.pk}} WHERE {sourceCatalog.id} = '" + sourceCatalog + "'
AND {sourceCatalogVersion.version} = '" + sourceCatalogVersion + "' AND {targetCatalog.id} = '" +
targetCatalog + "' AND {targetCatalogVersion.version} = '" + targetCatalogVersion + "'";
FlexibleSearchQuery fsQuery = new FlexibleSearchQuery(query);
fsQuery.setStart(startCounter);
fsQuery.setCount(batchSize);
SearchResult queryResults = fss.search(fsQuery);
List orphanedItemSyncTimestamps = queryResults.getResult();
out.println("I'm about to delete " + orphanedItemSyncTimestamps.size() + " orphaned
ItemSyncTimestamp(s)");
log.info("I'm about to delete " + orphanedItemSyncTimestamps.size() + " orphaned ItemSyncTimestamp(s)");
int deletedCount = 0;
for(ItemSyncTimestampModel orphanedItemSyncTimestamp: orphanedItemSyncTimestamps){
ms.remove(orphanedItemSyncTimestamp);
deletedCount++;
}
out.println(deletedCount + " orphaned ItemSyncTimestamp(s) deleted");
log.info(deletedCount + " orphaned ItemSyncTimestamp(s) deleted");
log.info("FINISHED BeanShellRemoveRelation");
JaloSession.getCurrentSession().setUser(previousUser);
out.println("#BeanShell now is executed with user rights:" + JaloSession.getCurrentSession().getUser());

14)
Launch of Synchronization from Europe Staged to Europe online(J4 in
figura 2 above)
From HMC -> Catalog->Catalog Management Tools-Syncronization:

Select hm-europeProduct and click on next. Then select J7 record and start:

15)
Launch of queries for hmsize before start the indexing process, from
HAC->FlexibleSearch and tab SQL Query(launch one query at a time):
CONFIDENTIAL

June 24st, 2014

Page 20

UPDATE hmsize SET p_marketcode = (SELECT p_code FROM hmmarket WHERE hmsize.p_market =
hmmarket.pk)
UPDATE products SET (p_sizeCode, p_sizeScaleCode) = (SELECT p_sizeCode, p_sizeScaleCode FROM hmsize
WHERE products.p_hmsize = hmsize.pk)

16)

Launch of SQL Query to disable old pick up point :

17)

Launch of beanshells to reclamate Price marker:


a) Remove price Marker Beanshell:

Update pointofservice set p_active = 0 where p_active = 1

org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger("BeanShell


Price Marker Change");
LOG.info("BeanShell Remove Promotional Marker - Start");
java.util.List pks = java.util.Arrays.asList(new java.lang.Long[]
{8805290049537L, 8804466425857L, 8804442243073L, 8804414160897L,
8804124033025L, 8803970809857L, 8802939633665L, 8802924986369L,
8802924822529L, 8802710192129L, 8801815003137L, 8801812414465L,
8801037647873L, 8800497434625L, 8799077269505L, 8799040503809L,
8799011700737L, 8798980833281L, 8798940332033L, 8798600396801L,
8798533779457L, 8798532796417L, 8796243558401L, 8796228812801L,
8796217671681L, 8796209053697L, 8796200468481L, 8796145188865L,
8796129558529L, 8796129263617L});
de.hybris.platform.servicelayer.search.FlexibleSearchQuery query = new
de.hybris.platform.servicelayer.search.FlexibleSearchQuery("SELECT {pk}
FROM {Product} WHERE {pk} IN (?pks)",
java.util.Collections.singletonMap("pks", pks));
de.hybris.platform.servicelayer.search.FlexibleSearchService
flexibleSearchService =
(de.hybris.platform.servicelayer.search.FlexibleSearchService)
de.hybris.platform.core.Registry.getApplicationContext().getBean("flexibleSear
chService");
de.hybris.platform.servicelayer.model.ModelService modelService =
(de.hybris.platform.servicelayer.model.ModelService)
de.hybris.platform.core.Registry.getApplicationContext().getBean("modelServic
e");
LOG.info("Run query: " + query);
de.hybris.platform.servicelayer.search.SearchResult result =
flexibleSearchService.search(query);
java.util.List errorCodes = new java.util.ArrayList();
for(de.hybris.platform.core.model.product.ProductModel productModel :
result.getResult()){
LOG.info("Remove price marker " + productModel.getPromotionMarker() +
" on product " + productModel);
productModel.setPromotionMarker(null);
try{
modelService.save(productModel);
}
catch(Exception ex){
LOG.error("It is impossible to save product model " +
productModel.getCode());
LOG.error("ERROR: " + ex.getMessage());
errorCodes.add(productModel.getCode());
}
}
LOG.info("Product with error: " + errorCodes);
LOG.info("BeanShell Remove Promotional Marker - End");

b) Move Price Marker Beanshell:


org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger("BeanShell Price Marker
Change");

CONFIDENTIAL

June 24st, 2014

Page 21

LOG.info("BeanShell Move Promotional Marker - Start");


java.util.List pks = java.util.Arrays.asList(new java.lang.Long[]{8805236408321L,
8805236375553L, 8804595662849L, 8804567646209L, 8804422483969L,
8804419305473L, 8802478194689L, 8802478096385L});
de.hybris.platform.servicelayer.search.FlexibleSearchQuery query = new
de.hybris.platform.servicelayer.search.FlexibleSearchQuery("SELECT {pk} FROM
{HMProductGroup!} WHERE {pk} IN (?pks)", java.util.Collections.singletonMap("pks", pks));
de.hybris.platform.servicelayer.search.FlexibleSearchService flexibleSearchService =
(de.hybris.platform.servicelayer.search.FlexibleSearchService)
de.hybris.platform.core.Registry.getApplicationContext().getBean("flexibleSearchService");
de.hybris.platform.servicelayer.model.ModelService modelService =
(de.hybris.platform.servicelayer.model.ModelService)
de.hybris.platform.core.Registry.getApplicationContext().getBean("modelService");
LOG.info("Run query: " + query);
de.hybris.platform.servicelayer.search.SearchResult result =
flexibleSearchService.search(query);
java.util.List errorCodes = new java.util.ArrayList();
for(goep.hm.core.model.HMProductGroupModel productGroupModel : result.getResult()){
de.hybris.platform.core.model.product.ProductModel productModel =
productGroupModel.getBaseProduct();
if(productGroupModel.getPromotionMarker()!=null){
LOG.info("Move price marker " + productGroupModel.getPromotionMarker()
+ " from article group " + productGroupModel + " to " + productModel);
productModel.setPromotionMarker(productGroupModel.getPromotionMarker());
productGroupModel.setPromotionMarker(null);
try{
//modelService.saveAll(new Object[]{productModel,
productGroupModel});
modelService.save(productModel);
modelService.save(productGroupModel);

}
catch(Exception ex){
LOG.error("It is impossible to save product model " +
productModel.getCode() + " and product group " + productGroupModel.getCode());
errorCodes.add("[" + productModel.getCode() + ", " +
productGroupModel.getCode() + "]");
}
}else{
LOG.info("Price marker of " + productGroupModel.getCode() + " is null and
we don't move it");
}
}
LOG.info("Product with error: " + errorCodes);
LOG.info("BeanShell Move Promotional Marker - End");

c) Change HMMarker Beanshell:


System.out.println("BeanShell Change Promotional Marker Image - Start");
java.lang.String fileName = System.getProperty("java.io.tmpdir") +
java.io.File.separator + "50-Black.png";
org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger("BeanShell
Price Marker Change");
try{
LOG.info("BeanShell Change Promotional Marker Image - Start");
java.util.List pks = java.util.Arrays.asList(new java.lang.Long[]
{8796781521659L, 8796846795515L, 8796781554427L, 8796781325051L,
8796846861051L, 8796846729979L, 8796781357819L, 8796846828283L,
8796814027515L, 8796813961979L, 8796846762747L, 8796813994747L,
8796355242747L, 8796355341051L, 8796355275515L, 8796781488891L,
8796322474747L, 8796322573051L, 8796322507515L, 8796781292283L});
de.hybris.platform.servicelayer.search.FlexibleSearchQuery query = new
de.hybris.platform.servicelayer.search.FlexibleSearchQuery("SELECT {pk} FROM
{HMMarker} WHERE {pk} IN (?pks)", java.util.Collections.singletonMap("pks",
pks));

CONFIDENTIAL

June 24st, 2014

Page 22

de.hybris.platform.servicelayer.search.FlexibleSearchService
flexibleSearchService =
(de.hybris.platform.servicelayer.search.FlexibleSearchService)
de.hybris.platform.core.Registry.getApplicationContext().getBean("flexibleSearchS
ervice");
de.hybris.platform.servicelayer.model.ModelService modelService =
(de.hybris.platform.servicelayer.model.ModelService)
de.hybris.platform.core.Registry.getApplicationContext().getBean("modelService")
;
de.hybris.platform.servicelayer.media.MediaService mediaService =
(de.hybris.platform.servicelayer.media.MediaService)
de.hybris.platform.core.Registry.getApplicationContext().getBean("mediaService")
;
LOG.info("Run query: " + query);
de.hybris.platform.servicelayer.search.SearchResult result =
flexibleSearchService.search(query);
java.util.List errorCodes = new java.util.ArrayList();
for(goep.hm.core.model.HMMarkerModel marker : result.getResult()){
de.hybris.platform.core.model.media.MediaModel mediaModel =
marker.getImage();
if(mediaModel != null) {
LOG.info("Change image for marker image: " +
mediaModel);
try{
java.io.FileInputStream inputStream = new
java.io.FileInputStream(new java.io.File(fileName));
mediaService.setStreamForMedia(mediaModel,
inputStream);
try{
modelService.save(mediaModel);
}
catch(Exception ex){
LOG.error("It is impossible to save product
model " + mediaModel.getName());
errorCodes.add(mediaModel.getName());
}
}
catch(Exception ex){
LOG.error("It is impossible to load image: " + ex);
}
}
else{
LOG.error("Marker " + marker + " hasn't got image!");
}
}
}
catch(java.io.IOException ex){
LOG.error("Error: " + ex);
}
LOG.info("Marker with error: " + errorCodes);
LOG.info("BeanShell Change Promotional Marker Image - End");

18)
Launch of Full indexing hm-franceProductHMIndex, from HMC -> System>Facet search->Indexer operation wizard:

CONFIDENTIAL

June 24st, 2014

Page 23

Then click start and monitoring the by solr web interface the related master
index:
you can use firefox with proxy activate, like this:

Then go to the url ip_address_solr_host:8080/solr and click on


Admin_master_hm_france_Product

CONFIDENTIAL

June 24st, 2014

Page 24

Then click on FULL INTERFACE

And write json in field Output Type:

Then click on search.


You have to obtain the number of product that has been indexed:

CONFIDENTIAL

June 24st, 2014

Page 25

I053_PickupPointDat
aLoad_3PP01_20140731041803850.csv

19)
Upload file
in the folder /mnt/integration/esbhybris/esb/out/i053/pending/
And run the job pointOfServiceDataLoaderCronJob;
20)

Re-enable all jobs launching this impex:

INSERT_UPDATE CronJob;code[unique=true];active;retry
;full-hm-franceProductOOBIndex-cronJob;true;true
;full-hm-franceCategoryIndex-cronJob;true;true
;full-hm-franceProductHMIndex-cronJob;true;true
;update-hm-franceCategoryIndex-cronJob;true;true
;update-hm-franceProductHMIndex-cronJob;true;true
;update-hm-franceProductOOBIndex-cronJob;true;true
;full-hm-italyProductOOBIndex-cronJob;true;true
;full-hm-italyCategoryIndex-cronJob;true;true
;full-hm-italyProductHMIndex-cronJob;true;true
;update-hm-italyCategoryIndex-cronJob;true;true
;update-hm-italyProductHMIndex-cronJob;true;true
;update-hm-italyProductOOBIndex-cronJob;true;true
;full-hm-spainProductOOBIndex-cronJob;true;true
;full-hm-spainCategoryIndex-cronJob;true;true
;full-hm-spainProductHMIndex-cronJob;true;true
;update-hm-spainCategoryIndex-cronJob;true;true
;update-hm-spainProductHMIndex-cronJob;true;true
;update-hm-spainProductOOBIndex-cronJob;true;true
;full-hm-portugalProductOOBIndex-cronJob;true;true
;full-hm-portugalCategoryIndex-cronJob;true;true
;full-hm-portugalProductHMIndex-cronJob;true;true
;update-hm-portugalCategoryIndex-cronJob;true;true
;update-hm-portugalProductHMIndex-cronJob;true;true
;update-hm-portugalProductOOBIndex-cronJob;true;true
;full-hm-chinaProductOOBIndex-cronJob;true;true
;full-hm-chinaCategoryIndex-cronJob;true;true
;full-hm-chinaProductHMIndex-cronJob;true;true
;update-hm-chinaCategoryIndex-cronJob;true;true
;update-hm-chinaProductHMIndex-cronJob;true;true
;update-hm-chinaProductOOBIndex-cronJob;true;true
;paymentProcessCronJob;true;true
INSERT_UPDATE MulticountryCronJob;code[unique=true];active;retry
;asiaChangeOrderStatusCronJob;true;true
;europeChangeOrderStatusCronJob;true;true

CONFIDENTIAL

June 24st, 2014

Page 26

;asiaOrderBlindReturnsImportJob;true;true
;europeOrderBlindReturnsImportJob;true;true
;europeOrderToSAPExportJob;true;true
;europeConsignmentExportJob;true;true
;asiaConsignmentExportJob;true;true
;asiaStockAdjustmentDataLoaderCronJob;true;true
;europeStockAdjustmentDataLoaderCronJob;true;true
INSERT_UPDATE CronJob;code[unique=true];active;retry
#;stockAdjustmentDataLoaderCronJob;true;true
;Cluster 0: Lucenesearch-RebuildIndex-Job;true;true
;Cluster 0: Lucenesearch-UpdateIndex-Job;true;true
;subscriberUserExporterJob;true;true
;imagesImportCronJob;true;true
;fullCustomerExportCronJob;true;true
;orderHistoryExportJob;true;true
;stockDailySnapshotCronJob;true;true
;importCatalogCronJob;true;true
;orderSettlementJob;true;true
;consignmentCreationJob;true;true
;pendingPaymentCheckCronJob;true;true

21)
Set the property is.migration to false
in HAC ->Console->Configuration, by searching the name of property:

22)
Update with only hmcore checked and with sync Products & Content
Catalogs setted to no, to remove all no longer used sync-jobs:

23)
Launch of Synchronization from Master to Asia (J3 in figura 1 above)
CONFIDENTIAL
June 24st, 2014
Page 27

From HMC -> Catalog->Catalog Management Tools-Syncronization:

Select hm-masterProduct and click next. Then select J3 record and start:

24)
Launch of Synchronization from Asia Staged to Asia Online (J5 in figura 2
above)
From HMC -> Catalog->Catalog Management Tools-Syncronization:

Select hm-asiaProduct and click next. Then select J4 record and start:
CONFIDENTIAL

June 24st, 2014

Page 28

Set catalog.sync.worker to 1 in local.properties


Restart admin node and commerce nodes.
FINISH

CONFIDENTIAL

June 24st, 2014

Page 29

Вам также может понравиться