Try our conversational search powered by Generative AI!

Global Price Increase

jim
jim
Vote:
 

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
Vote:
 

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
jim
Vote:
 

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
jim
Vote:
 

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
Vote:
 

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
Vote:
 

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
jim
Vote:
 

Thanks Quan I'll keep you posted

#181091
Aug 08, 2017 15:56
jim
Vote:
 

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
Vote:
 

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
jim
Vote:
 

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
jim
Vote:
 

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
Vote:
 

Hi,

                else if (child is NodeContent)

Should be 

else if (child is Node Content || child is CatalogContent)

because children of RootContent are CatalogContent. I'll update the code in the blogpost

P/S: Thanks for your purchase :)

#181200
Aug 12, 2017 21:31
jim
Vote:
 

Thanks you have been a huge help.

#181287
Aug 15, 2017 20:11
jim
Vote:
 

Is there a good reason why the price entries would be updating multiple times. I see 4 updates against the pricevalue. It seems to me that the product is being updaed in a recursive manner. After which the actual child entries are being updated again. 

#181288
Aug 15, 2017 21:29
Vote:
 

No It should not work that way. Are you using SQL Profiler to profile the queries? What are the parameters?

#181290
Aug 15, 2017 22:28
jim
Vote:
 

I jsut checked again and the prices look correct CMS but when I change the quantity it does not update the total, istead the List Price and Total fields are blank

Quantity of 1

List Price: $0.66
Total: $0.66
Quantity of more than 1
List Price:
Total:
#181304
Aug 15, 2017 23:23
Vote:
 

Not sure which total are you talking about. If the prices looks correct in Catalog UI (the readonly price view) then it should work ...

#181308
Aug 15, 2017 23:28
jim
Vote:
 

Check out the link. Essentially the Global Increase code worked, the pricess look good but when I browse and try to change the qty on the orderform, both prices go blank. It seesm like either a caching issue or some logig that deals with Quantity discounts. I am almost there I thnk Quan.

Quantity Calculation after Update

#181311
Aug 16, 2017 2:44
Vote:
 

Can you post the prices here? Is there a price for quantity 2? 

#181336
Aug 16, 2017 14:15
jim
Vote:
 

Thanks Quan

The link to the pdf is below, I updated it and added the Quantity Pricing area. The price displays correctly when the quantity is 1 but anything else causes the List: and Total: to go blank. I feel as though the system is calculating based on quantity blocks (1-249, 250-1000, etc...). I also noticed that the prices in the Quantity Pricing are below the item have not been updated. I wonder is this cached somewhere or did the update program miss these items. 

Global Price Update-Correct price with QTY of 1.pdf

#181348
Aug 16, 2017 16:00
Vote:
 

By "prices" I meant the price in Catalog UI, something like this

There is no "block", but price is selected by the min quantity value. So if the price has min quantity = 2 then it will be selected when the item quantity = 3, but not when item quantity =1 

#181382
Aug 17, 2017 13:28
jim
Vote:
 

Quan

Sorry for wasting time this was seems to be a non-issue. I ran the dev console and found a call to GetProductPrices the was giving a faulty reponse because the QA license is expired. The response is given afteer the banner text. 

<div style="z-index: 30000; text-align: left; color: black; font-size: 0.8em; background-color: #e3e1dd; font-family: Verdana, Arial, sans-serif; position: absolute; left: 30%; top: 30%; padding: .5em; width: 40em; border: .1em solid #575757; height: auto;"><div>There is a license error on this site:<div style="margin: 0.5em 0em; border:solid 1px #575757; background-color:#FFD053; padding-left: 1.0em;">License has expired</div>The Web site remains functional, but this message will be displayed until the license error has been corrected.<br /><br />To correct this error:<ul><li>Ensure that you have a valid license file for the site configuration.</li><li>Store the license file in the application directory.</li></ul>If you do not have a license file, please request one from <a href="http://license.episerver.com/">EPiServer License Center</a>.</div></div>

{"Price":3.62,"ExtendedPrice":7.24,"PriceFormatted":"$3.62","ExtendedPriceFormatted":"$7.24","PricingGroups":[],"ResponseSuccess":true,"ResponseMessage":"--> Price was retrieved successfully","ValidationErrors":[],"ErrorCode":0,"ResponseMessageType":0}

#181401
Aug 17, 2017 21:21
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.