Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Carlos Tarazona 24 posts 43 karma points
    Jun 25, 2012 @ 16:33
    Carlos Tarazona
    0

    Content changes not updating/refreshing

    Hi,

    I am doing pessimistic stock keeping with Tea Commerce.  I am maintaining stock across multiple nodes where this product is.  In other words, the products are in the master catalog and an instance exists in 3 places in the content tree.  These prodcuts have only a stock of 1 so when someone adds it to their cart it needs to be reflected immediately on the front end and from different pages.

    So I can see from inside the CMS backend that the stock values have been changed.  The issue is that the front end is not reflecting that which I imagine is a caching issue. I have read this:

    http://our.umbraco.org/wiki/reference/api-cheatsheet/publishing-and-republishing

    I was either already doing what it said or added it but the front end still doesn't update until after a few minutes.  When I change a stock value in the orderline added and removed events I am:

    1. Calling order.Save()

    2. Republishing the document by calling this function:

            void PublishUpdate(int NodeId)

            {

                System.Xml.XmlDocument xd = new System.Xml.XmlDocument();

     

                Document tempDoc = new Document(NodeId);

                User author = User.GetUser(0);

                tempDoc.Publish(author);

                tempDoc.XmlGenerate(xd);

                umbraco.library.UpdateDocumentCache(tempDoc.Id);

                umbraco.library.RefreshContent();

            }

     

    3. Calling umbraco.library.RefreshContent(); after all changes have been made.

     

    Any advice?  Is there something else I can do?  Republishing the entire site seems to work but it takes so long who knows if it really helped or it just took so long it was refreshed already anyway.

    Carlos

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Jun 25, 2012 @ 19:06
    Alex Skrypnyk
    0

    Hi Carlos,

    Try something like that:

    DocumentType dt =DocumentType.GetByAlias("YourDocType"); 
    User author =User.GetUser(0);

    Document doc =Document.MakeNew("My new document", dt, author,1018);

    //after creating the document, prepare it for publishing

    doc
    .Publish(author);

    //Tell umbraco to publish the document
    umbraco
    .library.UpdateDocumentCache(doc.Id);
  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Jun 25, 2012 @ 19:06
  • Carlos Tarazona 24 posts 43 karma points
    Jun 25, 2012 @ 19:23
    Carlos Tarazona
    0

    Hi Alex,

    Thanks but I am not creating a new document just updating an existing one.  Any other ideas?  Thanks.

    Carlos

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Jun 25, 2012 @ 20:28
    Alex Skrypnyk
    0

    Just add Save method before publishing:

     

               Document test = new Document(1100);

               test.Save();

               User author = User.GetUser(0);

               test.Publish(author);

     

  • Rune Grønkjær 1372 posts 3103 karma points
    Jun 26, 2012 @ 08:20
    Rune Grønkjær
    0

    Hi Guys,

    You might also want to update the document cache after publishing. That should make sure that your changes are updated on the website.

          umbraco.library.UpdateDocumentCache( node.Id );
    

    /Rune

  • Carlos Tarazona 24 posts 43 karma points
    Jun 27, 2012 @ 17:37
    Carlos Tarazona
    0

    Hi Rune,

    This didn't work for me.  And actually I was already doing that if you look at the code above.  But that did give me the idea that I should try republishing the parent node.  That didn't work though.

    However, this isn't an issue for me now because the the latest build of Tea Commerce fixed a properties bug so I was able to revert back to managing the products solely in the master catalog.

    Thanks for everyone's help.

    Carlos

     

  • Anders Burla 2560 posts 8256 karma points
    Jun 27, 2012 @ 21:49
    Anders Burla
    0

    Weird :)

    If by any chance that you find one of the answers as a solution for your question. Could you please mark it - thanks :)

    Kind regards
    Anders

Please Sign in or register to post replies

Write your reply to:

Draft