Announcement

Collapse
No announcement yet.

Product Counts in Category Tree and Custom Category Fields

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

    Product Counts in Category Tree and Custom Category Fields

    Just wanted to post this info about custom category fields:

    In the category tree, we wanted to list the number of products in each category (product count). We used the Emporium Plus Toolkit cxp function to get the product counts. This made the site very slow due to the number of categories. Bill suggested we put the product count in a category custom field to make it faster.

    Because we had so many categories to edit, I coded a custom page for the webmaster that lists the category codes, product counts (from cxp) and category names in this format:

    Category_Code|Product_Count|Category_Name

    The webmaster can periodically display this page (after they refresh the products in the store), copy the content of this page into a text editor, save it, and import it into Miva using the Category import utility. A couple of problems we encountered:

    (1) Miva requires the category name to do the import. This should not be required - only the category code should be required. However it was not a big deal to add the category name since we had just pulled all the data from the live site.

    (2) The Miva import utility changed our "0" (zero) product counts to null. It should have put the "0" in our custom field. We just coded around it. (It would have been nice to be able to check for null vs 0.)

    Another advantage of this is that we can suppress from the category tree the categories that have no products.

    The site works much faster now.

    Here is the code for pulling the category custom field from Bill's Toolkit page:

    Code:
    <mvt:item name="toolkit" param="customcategory|cattotal|l.all_settings:category:id|productcount" />
    &mvte:global:cattotal;
    Doreen Jeffers
    iMarks Web Solutions
    www.iMarksWeb.com

    #2
    Re: Product Counts in Category Tree and Custom Category Fields

    Why are you doing it the hard way. When I told you the suggestion, I also sent you the updated Tool Kit module. Under admin > utilities (the + to the left of utilities) there is a link for tool kit. Click it. There is a form with a button to click that counts all the products in all the categories (very quickly) and puts that value in the custom category fields. It took 1 second for my test store. No import necessary. Then you use the regular custom category field code to display the counts.
    <mvt:if expr="NOT ISNULL l.settings:cattree_category:customfield_values:cus tomfields:productcount">
    (&mvt:cattree_category:customfield_values:customfi elds:productcount;)
    </mvt:if>
    <mvt:if expr="NOT ISNULL l.settings:cattree_category:customfield_values:cus tomfields:cathaschild">
    +
    </mvt:if>

    On the category page (not the tree) you use the example you showed above.
    <mvt:item name="toolkit" param="customcategory|cattotal|l.all_settings:cate gory:id|productcount" />
    &mvte:global:cattotal;
    Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
    Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
    Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
    Facebook http://www.facebook.com/EmporiumPlus
    Twitter http://twitter.com/emporiumplus

    Comment


      #3
      Re: Product Counts in Category Tree and Custom Category Fields

      Sorry, Bill, I was working from a previous email and a copy of toolkit you sent me the afternoon before. I built the import page before you sent the new version of toolkit.

      I will try installing the 8/26 version and see if I can find the option you referenced in that newer version. Thank you.
      Doreen Jeffers
      iMarks Web Solutions
      www.iMarksWeb.com

      Comment


        #4
        Re: Product Counts in Category Tree and Custom Category Fields

        Hi!

        I was actually able to follow this thread and have the product count posting on the category page (next to the category title). However, I was wondering if there is a way to have this post the product count within the category tree next to (or as part of) the link to each category. Everything I've tried puts the count either above or below the category tree.

        Is what I am trying to do possible?
        Thanks!
        JS
        Last edited by sylvia8308; 05-14-12, 06:23 AM.

        Comment


          #5
          Re: Product Counts in Category Tree and Custom Category Fields

          Originally posted by wcw View Post
          Why are you doing it the hard way. When I told you the suggestion, I also sent you the updated Tool Kit module. Under admin > utilities (the + to the left of utilities) there is a link for tool kit. Click it. There is a form with a button to click that counts all the products in all the categories (very quickly) and puts that value in the custom category fields. It took 1 second for my test store. No import necessary. Then you use the regular custom category field code to display the counts.
          <mvt:if expr="NOT ISNULL l.settings:cattree_category:customfield_values:cus tomfields:productcount">
          (&mvt:cattree_category:customfield_values:customfi elds:productcount;)
          </mvt:if>
          <mvt:if expr="NOT ISNULL l.settings:cattree_category:customfield_values:cus tomfields:cathaschild">
          +
          </mvt:if>

          On the category page (not the tree) you use the example you showed above.
          <mvt:item name="toolkit" param="customcategory|cattotal|l.all_settings:cate gory:id|productcount" />
          &mvte:global:cattotal;

          Sometimes the recent crappy search results can pull in an old answer that still works. Now if I could only find the original post
          Leslie Kirk
          Miva Certified Developer
          Miva Merchant Specialist since 1997
          Previously of Webs Your Way
          (aka Leslie Nord leslienord)

          Email me: [email protected]
          www.lesliekirk.com

          Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

          Comment

          Working...
          X