Announcement

Collapse
No announcement yet.

Loading a specific product on a CTGY page

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Loading a specific product on a CTGY page

    I have a New Arrivals category that uses Toolkit to display the last 30 products added to the database. I'm doing a redesign of the site using a ReadyTheme, so I figured I might as well modernize my New Arrivals code to take advantage of the pricing calculated by the Runtime_Product_Load_Code function.

    I copied the sample code into the category's header and plugged in an existing product code, but I got nothing.

    <mvt:do name="l.return" file="g.Module_Library_DB" value="Runtime_Product_Load_Code( 'product_code', l.product )" />
    &mvt:product:code;

    What am I missing here?

    Thanks,
    Todd

    #2
    Your code looks fine, if you're sure that the 'product_code' match any existing product code.

    Part of code from my CTGY page (works fine)
    Code:
    <mvt:do name="l.return" file="g.Module_Library_DB" value="Runtime_Product_Load_Code( g.brother_product_code, g.ret )" />    
    <mvt:if expr="g.ret:code">
          &mvt:global:ret:code;
    </mvt:if>

    Comment


      #3
      The problem was that I took the code sample at its word. I can't use l.product as shown or any local variable for that matter, but it works fine if I switch to a global variable. Thanks for setting me straight.

      Comment


        #4
        For the record, I've been struggling with the code to automatically list the 30 most recent product additions in an empty category called new-arrivals. It really boiled down to making sure pricing was correct with all of the possible discounts and such. I knew I didn't want to manually assign/unassign these products.

        After hours of trying this code and that code, I finally realized that there is no need at all to write code to replicate a category product layout listing within my New Arrivals category. It's much, much easier to automatically add and remove the products every time the category is visited, so I added the following code to the bottom of my CTGY template. Problem solved!

        <mvt:if expr="l.settings:category:code EQ 'new-arrivals'">
        <mvt:do file="g.Module_Library_DB" name="l.success" value="CategoryXProduct_Delete_All_Category(l.sett ings:category:id)" />

        <mvt:do file="g.Module_Library_DB" name="l.success" value="Product_Load_Last(g.thisprod)" />
        <mvt:assign name="g.prodcount" value="1" />
        <mvt:while expr="g.prodcount LE 30">
        <mvt:do file="g.Module_Library_DB" name="l.success" value="CategoryXProduct_Insert(l.settings:category :id, g.thisprod:id)" />
        <mvt:do file="g.Module_Library_DB" name="l.success" value="Product_Load_Previous(g.thisprod, g.lastprod)" />
        <mvt:assign name="g.thisprod" value="g.lastprod" />

        <mvt:assign name="g.prodcount" value="g.prodcount + 1" />
        </mvt:while>
        </mvt:if>

        Comment


          #5
          A couple thoughts here...

          While that code does work, its quite a bit of overhead to un-assign and then re-assign all products from a category each time the page loads.

          You could also use a ReadyTheme Product List which can be set to load the 30 products from all products and then reverse the sort so you get the last 30.


          Brennan Heyde
          VP Product
          Miva, Inc.
          [email protected]
          https://www.miva.com

          Comment


            #6
            I realize that it is a bit of work for the server to do that, but this page is not visited a lot, surprisingly.

            I have almost zero experience using ReadyThemes, so you'll have to bear with me here. I have no idea what a ReadyTheme Product List is. Where can I find some info on these features?

            Comment


              #7
              Found it here https://docs.miva.com/template-langu...-documentation, and got it working. Thanks for the pointing me in the right direction Brennan.

              Comment


                #8
                FYI. The reason l.products didn't work above is because you used the SMT 'token' expressions of &mvt:product:code;, which actually assumes the variable name is really l.settings:product. However, its also a good idea not to re-use variables miva creates as you could have unintended consequences. So, while globals are fine (and even necessary at times) you can use structures like l.settings:xxx:products and the like (just remember they are expressed as tokens in the format &mvt:xxx:product;
                Bruce Golub
                Phosphor Media - "Your Success is our Business"

                Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                phosphormedia.com

                Comment


                  #9
                  Thanks for clearing that up Bruce.

                  Comment

                  Working...
                  X