Using config parameters in impex file

We need use processor in our impex file for accessing config settings like below.

UPDATE GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor]; pk[unique=true]
$configvar = $config-db.port

UPDATE MyItem; name[unique=true]
             ; $configvar

hybris ant targets

ant customizeApply custom code changes and libraries.
ant serverUpdate tomcat settings.
ant updateMavenDependenciesUpdate maven ant dependencies.
ant updatesystemUpdate DB schema and import impexes.
ant -Dtenant=junit -DtypeSystemOnly=true initializeInitialize JUnit tenant with just type system.
ant allwebtests -Dtestclasses.packages=com.mkysoft.*Running all web tests in package.
ant alltests -Dtestclasses.packages=com.mkysoft.*Running all tests in package.
ant unittests -Dtestclasses.suppress.junit.tenant=true -Dtest=”com.mkysoft.hybris.MyClassTest”Running single class test.

Disable interceptors for impex

We can disable interceptors while importing impex files.

REMOVE Order[disable.interceptor.beans='orderPrepareInterceptor']; pk[unique = true]
; 1234567891234

INSERT_UPDATE Order[disable.interceptor.beans='orderPrepareInterceptor']; code[unique = true]
; order-123

Accsess backoffice config

While in backoffice in Adminstration Perspective you can press F4 button from keyboard. Then click menu icon on right corner for Show cockpit-config.xml option.

hybris system requirements

hybris minimum requirements by versions. Preferred DB charset is utf8 and collation is utf8_bin.

JVMDBSolrImageMagickTomcat
2205SapMachine 17.0MySQL 8.0 (jdbc 8.x)8.11.16.7.3-58.5.78
2105SapMachine 11.0MySQL 5.7 (jdbc  5.1.x), 8.0 (jdbc 8.x)Patch 1 <= 8.9.0,
Patch 2 = 8.10
Patch 3 >= 8.10.1
6.7.3-58.5.69
2011SapMachine 11 or Oracle JDK/JRE 11MySQL 5.7 (jdbc  5.1.x), 8.0 (jdbc 8.x)8.66.7.3-58.5.56
2005SapMachine 11MySQL 5.7 (jdbc 5.1.x), 8.0 (jdbc 8.x)8.4.06.7.3-58.5.51
1905SapMachine 11MySQL 5.6, 5.7 (jdbc  5.1.x), 8.0 (jdbc 8.x)7.76.7.3-58.5.40
1811Oracle 8.0 or SAP JVM 8.1MySQL 5.6, 5.7 (jdbc  5.1.x) )7.56.7.3-58.5.40
1808Oracle 8.0 or SAP JVM 8.1MySQL 5.6, 5.7 (jdbc  5.1.x) )7.46.7.3-5

hybris installer failed

If you are getting error while installing receipt like below, although you have set the parameter, check your maven settings for central repositories URLs start with HTTPS.

********************************************************************************************************
Either platform properties or system environment does not have the required property 'initialpassword.admin' set.
Please make sure to provide it in the recipe or in the system environment.

If you are running recipe using installer application you can set required property via option
-A local_property:initialpassword.admin=property_value

If missing property is initialpassword.admin then you can set it up using
shortcut -A initAdminPassword=admin_password
********************************************************************************************************

Maven disabled HTTP repositories. You can use below sample maven config file at <user-home>\.m2\settings.xml.

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <profiles>
    <profile>
      <id>default</id>
      <repositories>
        <repository>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
          <id>central</id>
          <url>https://repo1.maven.org/maven2</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
          <id>central</id>
          <url>https://repo1.maven.org/maven2</url>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>default</activeProfile>
  </activeProfiles>
</settings>

Source: https://stackoverflow.com/questions/59972570/why-does-hybris-ship-insecure-http-maven-repository-url-and-why-cant-we-overri

My hybris development environment test

I am using my company mac pro 2015 for a lot of thing. So I need different environment look like C#, hybris, ABAP, etc. These environment needs service look like db. These service using my ram always. So I am using VM for environment which are not used often. I created VM for new hybris versions for testing (docker cannot pause / resume systems yet). I try some scenarios for my best hybris development environment.

VM: OS version Centos 7, Java 8 u162, MySQL 5.7.21 and hybris version 6.6.

Enviroment Compile time (ant clean all)
Hybris files in host shared with guest vm 21 minutes 9 seconds
Hybris files in guest vm 3 minutes 8 seconds
2 minutes 29 seconds
Hybris files in guest vm and shared with host (without nfs optimization)  5 minutes 44 seconds

 

Creating history for item

If you want create history for item look like backoffice, you can use below example.

public void updateConsignmentStatus(String userUid, ConsignmentModel consignment, ConsignmentStatus status) {
  Map<string, object=""> originals = new HashMap();
  originals.put(ConsignmentModel.STATUS, consignment.getStatus());

  consignment.setStatus(status);

  Map<string, object> news = new HashMap();
  news.put(ConsignmentModel.STATUS, consignment.getStatus());

  final SavedValues savedValues = JaloConnection.getInstance().logItemModification(consignment.getPk(), news, originals, false);
  savedValues.setUser(UserManager.getInstance().getUserByLogin(userUid));
  modelService.saveAll();
}

Creating,updating or deleting other items in interceptor

public class MyCustomerPrepareInterceptor implements PrepareInterceptor {
private static final Logger LOG = Logger.getLogger(MyCustomerPrepareInterceptor.class);

@Override
public void onPrepare(CustomerModel customerModel, InterceptorContext interceptorContext) throws InterceptorException {
  . . .
  final MyItemModel myItem = 
  interceptorContext.getModelService().create(MyItemModel.class);
  interceptorContext.registerElement(myItem);
  //interceptorContext.registerElementFor(myItem, PersistenceOperation.DELETE);
  . . .
}