Global Price Increase

Member since: 2017

Hello All

Commerce Version 5.15

CMS 8.51

I would greatly appreciate your input. I am fairly new to Episerver (finding it pretty amazing btw) and I have been tasked with implmenting a 5% price increase across the board, all prices. I have heard a few different suggestions but I am trying decide on a failry safe and expedient course of action. 

Your input is greatly welcomed.

#180971 Aug 03, 2017 21:58
  • Member since: 2011

    I'm not sure there was a 5.15. Perhaps it's 8.15?

    Of course the safest way to do such thing is to use IPriceServiceDetail to load all prices, update the unit prices then save back.

    The fastest way is to write some SQL code to update the table PriceValue directly, but I would advise against that, unless the previous method is too slow.

    #180987 Aug 04, 2017 9:55
  • Member since: 2017

    Thanks Quan

    We decided to go the IPriceServiceDetail route. What is the best way to get started. It seesm as the SDK examples are focused on modifying Commerce. Should we be using the Service API? I was hoping to get this done with a console app.

    #181057 Aug 08, 2017 1:17
  • Member since: 2017

    Quan

    I am new to Epi but I feel as though I should be able to instantiate an object of some Episerver Commerce type, then call upon the IPriceServiceDetail to use on of the methods like getPrices. However I am finding that there are not examples that describe this process. Should be using the Epi Server API, if so then I need to install it I guess.

    JL

    #181058 Aug 08, 2017 1:32
  • Member since: 2011

    You don't have to install anything else, IPriceServiceDetail is a builtin API in Episerver Commerce Core. The steps would be:

    • Start from RootContent (ReferenceConverter.GetRootLink())
    • Get the catalogs by IContentRepository.GetChildren
    • Recursively get the children of those catalogs. If the content is an entry, (ReferenceConverter.GetContentType(ContentReference) is a CatalogContentType.Entry, call IPriceServiceDetail.List(ContentReference)
    • Update the prices and then Save it via IPriceServiceDetail.Save(prices)
    #181063 Aug 08, 2017 8:46
  • Member since: 2011

    I'm on vacation today, so I have time to write something: http://vimvq1987.com/2017/08/permanently-drop-prices-products/

    #181072 Edited, Aug 08, 2017 9:46
  • Member since: 2017

    Thanks Quan I'll keep you posted

    #181091 Aug 08, 2017 15:56
  • Member since: 2017

    Quan - Update 

    This is a great post we are investigating now. What type of project do you use. Console (seems problematic), MVC, Web Forms, or does it matter?

    JL

    #181153 Aug 09, 2017 19:54
  • Member since: 2011

    You can make it a controller (I suppose your site is MVC?), or a WebForm page. Should avoid console because it's problematic to get the dependencies set up. 

    #181158 Aug 10, 2017 0:31
  • Member since: 2017

    Yea the console app was a rabbit hole, wow... Im writing in in a controller now.

    BTW... our other Architect and I venture into the database change on PriceValue and PriceDetail. Rather than update the actual records we used a historical approach where added new records for the targeted catalogcode and changed the validthrough date, restarted IIS and the price displayed did not change. So then we went ahead and updated the acutal record and price did change, but when we changed the qty the fields display fields went blank (weird). So I restored teh database.

    My boss wants to know how much Episerver charges to just make the change.

    #181159 Aug 10, 2017 1:32
  • Member since: 2017

    I decided to buy the proecommerce book, thanks for writing. I got commerce going (web form) after studyung the QuickSilver. I can get only the root with no children, can you see what i am doing wrong?

     IContentLoader contentLoader = ServiceLocator.Current.GetInstance<EPiServer.IContentLoader>();
               var priceDetailService = ServiceLocator.Current.GetInstance<IPriceDetailService>();
                PriceUpdater(contentLoader, priceDetailService);
               UpdatePrices(referenceConverter.GetRootLink());
              }
            public void PriceUpdater(IContentLoader contentLoader, IPriceDetailService priceDetailService)
            {
               _contentLoader = contentLoader;
                _priceDetailService= priceDetailService;
             }
            protected void UpdatePrices(ContentReference contentLink)
            {
                var children = _contentLoader.GetChildren<CatalogContentBase>(contentLink);
                foreach (var child in children)
                {
                    if (child is ProductContent)
                    {
                       
                        UpdateProductPrices(child.ContentLink);
                    }
                    else if (child is NodeContent)
                    {
                        UpdatePrices(child.ContentLink);
                    }
                }
            }
            protected void UpdateProductPrices(ContentReference contentLink)
            {
                var prices = _priceDetailService.List(contentLink);
                var newPrices = new List<IPriceDetailValue>();
                foreach (var price in prices)
                {
                    var newPrice = new PriceDetailValue(price)
                    {
                       // UnitPrice = new Money(0.95m * price.UnitPrice.Amount, price.UnitPrice.Currency)
                    };
                    newPrices.Add(newPrice);
                }
                _priceDetailService.Save(newPrices);
            }

     

    #181199 Aug 12, 2017 18:09
First   1 2 3   Last