Skip to Content
author's profile photo Former Member
Former Member

Handling Multiple Price Rows

Hi All,

I have a requirement to delete all price rows for a product before price feed comes to import into hybris through hot folder. why I want to delete is: We need to handle multiple price rows with different date ranges. So I made price row header more unique by making stnd end dates as unique in addition to existing product code and currency For example i receive two price rows with different date ranges, it is fine and will be imported. Tomorrow if I receive the one of the price row with update in start or end date, it will create a new price row right. So we want to delete all price rows and import every time the feed comes in to avoid remove unnecessary data. Can any one suggest how can we to handle this by deleting or by any other approach?

Thanks Praveen

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Posted on Dec 15, 2015 at 07:53 AM


    If you want to delete ALL price rows, use following impex statement:

     REMOVE PriceRow[batchmode=true];itemtype(code)[unique=true];

    Best Regards,

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Maciej,

      Daily we receive all prices for all products. We want to remove all prices for all products before we import the new ones only if the new prices are successful (success means data is valid and can be imported successfully

      Thanks, Praveen

  • author's profile photo Former Member
    Former Member
    Posted on Jan 23, 2019 at 11:56 AM


    Have a PriceRowInterceptor which implements ValidateInterceptor.

    This will get call whenever there is a change in price row.

    Override onValidate method.

    Get price from the product and delete rest of the price rows.

    Here is the sample code.

         Collection<PriceRowModel> prices;
         ProductModel product;
         if (!Objects.nonNull(catalogVersionService.getSessionCatalogVersions())) {
   "Setting catalog values in session");
             catalogVersionService.setSessionCatalogVersion(Config.getParameter("catalog"), Config.getParameter("version"));
         try {
   "New Pricerow found...");
             product = priceRowModel.getProduct();
             if (product == null) {
       "Getting productcode for the inserted row");
                 product = productService.getProductForCode(catalogVersionService.getCatalogVersion(Config.getParameter("catalog"),
             prices = product.getEurope1Prices();
             for (PriceRowModel price : prices) {
                 if (!price.equals(priceRowModel)) {
           "Deleting the old price" + price.getPrice());
           "Depathing the price");
         } catch (Exception e) {
             LOG.error("Error in Pricerow interceptor",e);
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 16, 2015 at 05:14 AM

    You can use other approach as well like overriding the europe1 pricefactory to get the price based on stnd end date logic. In this case, you can keep all the pricerows intact but select the right price programmatically and ignore others.

    How many pricerows can have a particular product and currency combination ?

    Though it will not fulfill your technical design, but it can satisfy the functional need.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks for suggestion. We have two currencies.With different date ranges at least two price rows for each currency. So totally it will be 4 price rows at-least for a product. To handle multiple price rows i have made start date and end date unique. So if there is any modification is required in start or end date of existing price row, then due to their uniqueness it will be imported again as different price row. So my technical design wants to delete and import every time.Even if i override price factory how do i know if there are multiple price rows which are applicable for todays date?

  • author's profile photo Former Member
    Former Member
    Posted on Dec 15, 2015 at 01:04 PM

    Hello Praveen

    Is difficult to give you a possible approach since we don’t have all details from your requirement. Anyway have a look to my suggestions to see if this helps.

    If you want to integrate both impex header in a single hot folder bean, you might need to change the hot folder configuration definition, because as far as I know you can only create one header per configuration bean.

    BUT you can have multiple beans in your configuration file, you just need to use the mapping converter to use the correct bean (header) depending of the file name. This means that in your configuration file (hot-folder-###-spring.xml) you could use 2 beans (1 for the Import header and 1 for the Remove header)

     <bean id="CONVERTER-NAME" class="de.hybris.platform.acceleratorservices.dataimport.batch.converter.mapping.impl.DefaultConverterMapping"

    With this explanation I think the best approach you could use is to create a bean configuration just for the REMOVE header and map it to a new CVS file.

    This approach means that you would receive a CVS file with your price rows and your products, and then you would need to create a new manually csv file that contain the products that are candidates of pricerows removal.

    Later just drop the new csv file before the original csv file into the hot folder. It may be a little confusing, so I have name it the files as PriceRow.csv and RemovePrice.csv and detail you a small workflow for better understanding

    • Create a new configuration bean to handle the new header for deleting price rows for certain products.

    • Create a converter mapping bean with the attribute p:mapping = to your new file name (RemovePrice in this example)

    • You will receive the PriveRow.csv

    • Extract the product codes and create a new csv file with those products (RemovePrice.csv)

    • Drop the RemovePrice.csv (this will remove the price rows of the candidate products before drooping the other csv into your hot folder)

    • Drop the PriceRow.csv file (the import should be successfully since you have removed already the conflicting price rows)

    Another approach but I don’t know if this suggestion can help you but, since you receive the price row every day, you could create a daily cronjob to remove the price row just before the import of the impex folder, But in this case you may need to delete all price rows without filter by product.

    I hope this suggestions help you to solve your issue

    Best Regards


    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      The trigger for the removal process will be after dropping in the hot older your manually created csv file with the products you need to remove the price row.

      I remains you that the CSV will be created by you so you will have to develop your own strategy to discard the pricess that should or shouldn't be removed

      In the other hand if you want to remove all prices from your platform i recommend you to use a daily cronjob that trigger the impex process of removal

  • Posted on Jan 23, 2019 at 01:56 PM

    Hi Penugonda ,

    has given the right answer, you apply it, you will find the right solution

    using PriceRowInterceptor and ValidateInterceptor to solve the problem

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.