Announcement

Collapse
No announcement yet.

Miva9 Listing All products under multiple categories

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

    Miva9 Listing All products under multiple categories

    Hi,
    Can anyone help me?

    I want to be able to list all the products under multiple sub-categories. e.g. When I click Drinkware + Kitchen, how do I list "ALL" the products under the main category Drinkware + Kitchen. Currently, I am only able to list one sub-category at a time. I wish to have a CTGY page that will list all the products in each of the categories below when they click DRINKWARE + KITCHENI know I can add each product individually in the main category DRINKWARE + KITCHEN, but I don't want to make that link clickable anywhere else. Is there a URL that will list all the sub-category products for my main category?

    Please see image and go to link https://www.hansonellis.com/personal...men-women.html

    Thanks,
    Keith
    Attached Files
    Last edited by howsimple; 06-26-18, 08:33 AM.

    #2
    You'd need to take the code from Content - Sub Categories (which creates a list of the sub cats for a top level cat) then INSIDE that array, run something like:

    Code:
    <mvt:do name="l.getCatID" file="g.Module_Library_DB" value="Category_Load_Code( 'category_code', l.settings:thisCat)" /> 
    <mvt:do name="l.getProductArray" file="g.Module_Library_DB" value="Runtime_ProductList_Load_Offset_Category( l.settings:thisCat:id, g.Offset, 100, g.NextOffset, l.settings:products )" /> 
    
    <mvt:foreach iterator="product" array="products">
    
       &mvt:product:code;<br>
       //Add the code you used for the product display of specific subcats
    
    </mvt:foreach>
    <mvt:assign name="l.settings:thisCat" value="''"/>
    <mvt:assign name="l.settings:products" value="''"/>
    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


      #3
      Thank you very much Bruce! I will give it a try.

      Comment


        #4
        Hey bruce, I've been trying to get this to work, and I think I'm "close". I have included the code below within the foreach loop for the SUBCATEGORIES. I am now "manually" assigning a category code to prove I can spit the products out, but I can't get this to actually show for the SUBCAT that is being looped through for each.....

        HTML Code:
        <mvt:do name="l.doit" file="g.Module_Library_DB" value="Category_Load_Code( 'pepsi', l.settings:thisCategory)" />
        <mvt:do name="l.doit" file="g.Module_Library_DB" value="Runtime_ProductList_Load_Offset_Category( l.settings:thisCategory:id, g.Offset, 100, g.NextOffset, l.settings:myProducts )" />
        
        <mvt:comment> Now you have an array of products so</mvt:comment>
        
        <mvt:foreach iterator="product" array="myProducts">
        
        &mvt:product:code;
        &mvt:product:name;
        &mvt:product:thumb;
        etc
        
        </mvt:foreach>
        What do I have to change that "pepsi" value to in order to get it to read the subcat that it's looping through? This is what it looks like in full context...

        HTML Code:
                    <mvt:foreach array="cattree_categories" iterator="category_children">
                        <mvt:if expr="l.settings:category_children:parent_id EQ l.settings:category:id">
                            <mvt:assign name="l.null" value="miva_array_insert(l.settings:subcategories, l.settings:category_children, -1)" />
                        </mvt:if>
                    </mvt:foreach>
                    <mvt:assign name="l.settings:subcategory_count" value="miva_array_elements(l.settings:subcategories)" />
                    <mvt:if expr="l.settings:subcategories GT 0">
                        <section class="o-layout u-grids-2 u-grids-3--l x-product-list">
                            <mvt:foreach iterator="subcategory" array="subcategories">
                                <div class="o-layout__item u-text-center x-product-list__item">
                                    <a class="u-block x-product-list__link" href="&mvte:subcategory:link;">
                                        <figure class="x-product-list__figure">
                                            <mvt:if expr="l.settings:subcategory:image">
                                                <img class="x-product-list__image" src="&mvt:subcategory:image;">
                                            </mvt:if>
                                            <figcaption>
                                                <strong class="x-product-list__name u-text-uppercase">&mvte:subcategory:name;</strong>
                                            </figcaption>
                                        </figure>
                                    </a>
                                </div>
        
                                <mvt:do name="l.doit" file="g.Module_Library_DB" value="Category_Load_Code( 'pepsi', l.settings:thisCategory)" />
                                <mvt:do name="l.doit" file="g.Module_Library_DB" value="Runtime_ProductList_Load_Offset_Category( l.settings:thisCategory:id, g.Offset, 100, g.NextOffset, l.settings:myProducts )" />
        
                                <mvt:comment> Now you have an array of products so</mvt:comment>
        
                                <mvt:foreach iterator="product" array="myProducts">
        
                                &mvt:product:code;
                                &mvt:product:name;
                                &mvt:product:thumb;
                                etc
        
                                </mvt:foreach>
        
        
        
                            </mvt:foreach>
                        </section>
                    <mvt:else>
                        <mvt:item name="category_listing" />
                    </mvt:if>
        Ted Hust
        AarcMediaGroup.com

        Celebrating 13 Years of Outstanding Service & Support
        Miva Merchant Design

        Comment


          #5
          Got it, changed the first line to this.....

          HTML Code:
          <mvt:do name="l.doit" file="g.Module_Library_DB" value="Category_Load_Code( l.settings:subcategory:code, l.settings:thisCategory)" />
          Ted Hust
          AarcMediaGroup.com

          Celebrating 13 Years of Outstanding Service & Support
          Miva Merchant Design

          Comment


            #6
            I was going to ask if you were trying to do something similar to this. I have been working hard with the help of a few people to convert the code used on the page from Toolkit to native coding.
            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


              #7
              OK, well this isn't quite working. What I have happening now is instead of just spitting out the subcategories products, if one category has 10 products, but the next only has 5, it's adding 5 products to the end of the one group to get it to the same #? Very odd.

              So how do I get the for each loop for the subcategory's products to stop at JUST WHAT'S ASSIGNED? Here's what I have so far.....

              HTML Code:
                                  <mvt:foreach array="cattree_categories" iterator="category_children">
                                      <mvt:if expr="l.settings:category_children:parent_id EQ l.settings:category:id">
                                          <mvt:assign name="l.null" value="miva_array_insert(l.settings:subcategories, l.settings:category_children, -1)" />
                                      </mvt:if>
                                  </mvt:foreach>
                                  <mvt:assign name="l.settings:subcategory_count" value="miva_array_elements(l.settings:subcategories)" />
                                  <mvt:if expr="l.settings:subcategories GT 0">
                                  <section class="o-layout">
                                      <div class="o-layout__item">
              
                                          <mvt:foreach iterator="subcategory" array="subcategories">
                                              <h2 class="u-text-uppercase"><a href="&mvte:subcategory:link;">
                                                  <strong>&mvte:subcategory:name;</strong>
                                              </a></h2>
              
                                              <mvt:do name="l.doit" file="g.Module_Library_DB" value="Category_Load_Code( l.settings:subcategory:code, l.settings:thisCategory)" />
                                              <mvt:do name="l.doit" file="g.Module_Library_DB" value="Runtime_ProductList_Load_Offset_Category( l.settings:thisCategory:id, g.Offset, 100, g.NextOffset, l.settings:myProducts )" />
              
                                              <table class="table-compact">
              
                                                  <mvt:foreach iterator="product" array="myProducts">
                                                  <mvt:assign name="l.uri:store_id" value="g.Store:id" />
                                                  <mvt:assign name="l.uri:screen" value="''" />
                                                  <mvt:assign name="l.uri:page_id" value="0" />
                                                  <mvt:assign name="l.uri:cat_id" value="0" />
                                                  <mvt:assign name="l.uri:product_id" value="1" />
                                                  <mvt:do file="g.Module_Feature_URI_DB" name="l.have_uri" value="URI_Load_Item_Canonical( l.uri, l.settings:canonical_uri )" />
                                                  <mvt:do name="l.success" file="g.Module_Library_DB" value="ProductImage_Load_Type(l.settings:product:id, 1, l.settings:imagetype)" />
                                                  <mvt:do name="l.success" file="g.Module_Library_DB" value="Image_Load_ID(l.settings:imagetype:image_id, l.settings:imagedata)" />
                                                  <mvt:assign name="g.subProductImage" value="g.baseurl $ l.settings:imagedata:image" />
                                                  <tr>
                                                      <td>&mvt:product:name;</td>
                                                  </tr>
                                                  </mvt:foreach>
                                              </table>
              
                                          </mvt:foreach>
                                      </div>
                                  </section>
              
              Ted Hust
              AarcMediaGroup.com

              Celebrating 13 Years of Outstanding Service & Support
              Miva Merchant Design

              Comment


                #8
                To better explain. Let's say the first subcat has 5 products, it will show them. Say the second subcat has 10 products. Still will be good. But if the third subcat only has 5 products, it will show those 5, and then spit out another 5 from the previous categories product list, to bring that sub-cats total to 10, and each after, no matter how many are in it, will fill out at 10 by filling in products from the row above. It's maddening haha. There has to be a way to exit, and only spit however many are SUPPOSED TO SHOW. I presume something with the offset is screwing it up.
                Ted Hust
                AarcMediaGroup.com

                Celebrating 13 Years of Outstanding Service & Support
                Miva Merchant Design

                Comment


                  #9
                  real quick cause i'm actually re-tiling the bathroom floor...

                  try replacing

                  l.settings:subcategories
                  in
                  <mvt:assign name="l.settings:subcategory_count" value="miva_array_elements(l.settings:subcategorie s)" />
                  with

                  l.settings:category_children
                  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


                    #10
                    Hey Bruce, tried that, same behavior. Any category that has fewer than the current max offset that I have set, it forces that loop to fill the difference with products from the previous. I had tried setting max to null, 0 and others and that didn't play.

                    And thanks for trying to help me debug this while tiling your bathroom haha.
                    Ted Hust
                    AarcMediaGroup.com

                    Celebrating 13 Years of Outstanding Service & Support
                    Miva Merchant Design

                    Comment


                      #11
                      Ted, are you trying to do something like this?

                      ​​​​​​https://www.kitchencabinetdepot.com/...-cabinets.html


                      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


                        #12
                        I just realized you are having the EXACT same problem I am having while trying to replace the Toolkit code on the page I previously linked. It's like the code wants to make sure all the categories have the same number product in it. Something is squirrelly with the code that Miva Dev Support helped me with:

                        <mvt:assign name="l.settings:subcat:id" value=" " />
                        <mvt:do name="l.result" file="g.Module_Library_DB" value="Category_Load_Code( g.Category_Code, l.settings:current_category )" />
                        <mvt:do name="l.result" file="g.Module_Library_DB" value="CategoryList_Load_Parent( l.settings:current_category:id, l.settings:sub_categories )" />
                        <mvt:assign name="l.subcat_count" value="miva_array_elements( l.settings:sub_categories )" />
                        <mvt:if expr="l.subcat_count GT 0">
                        <mvt:foreach iterator="subcat" array="sub_categories">
                        <h2 style="font-size:1.2rem; font-weight:bold;"><a name="&mvt:subcat:code;"></a><span style="color:#f00;">&mvte:subcat:name;</span></h2>
                        <mvt:assign name="l.settings:sub_categories2" value=" " />
                        <mvt:do name="l.result" file="g.Module_Library_DB" value="CategoryList_Load_Parent( l.settings:subcat:id, l.settings:sub_categories2 )" />
                        <mvt:assign name="l.subcat2_count" value="miva_array_elements( l.settings:sub_categories2 )" />
                        <mvt:if expr="l.subcat2_count GT 0">
                        <mvt:foreach iterator="subcat2" array="sub_categories2">
                        <p></p>
                        <a name="&mvte:subcat2:code;"></a>
                        <h3><strong style="color:#f00;">&mvte:subcat2:name;</strong>&nbsp; <a href="/&mvt:category:code;.html#top">
                        <strong style="color:#f00;">Back to top</strong></a></h3>
                        <mvt:comment>load first 100 products assigned to a specific category</mvt:comment>
                        <mvt:assign name="l.settings:products" value="0" />
                        <mvt:do name="l.result" file="g.Module_Library_DB" value="Runtime_ProductList_Load_Offset_Category( l.settings:subcat2:id, g.Offset, 100, g.NextOffset, l.settings:products )" />

                        <section>
                        <ul class="c-form-list o-layout o-layout--wide u-text-uppercase">
                        <li class="c-form-list__item o-layout__item u-width-7--m"> <span>Name</span></li>
                        <li class="c-form-list__item o-layout__item u-width-1--m"> <span>Price</span> </li>
                        <li class="c-form-list__item o-layout__item u-width-4--m"> </li>
                        </ul>
                        </section>
                        <mvt:foreach iterator="product" array="products">
                        <section>
                        <form class="o-layout__item u-width-12 inline-labeling ctgy-add-form" data-hook="purchase" action="&mvte:urls:BASK:auto;" method="post" name="add">
                        <input type="hidden" name="Action" value="ADPR" />
                        <input type="hidden" name="Product_Code" value="&mvte:product:code;" />
                        <ul class="c-form-list o-layout o-layout--wide u-text-uppercase">
                        <li class="c-form-list__item o-layout__item u-width-7--m"> <span>&mvt:product:name;</span> </li>
                        <li class="c-form-list__item o-layout__item u-width-1--m"> <span>&mvt:product:formatted_price; &mvt:product:price;</span> </li>
                        <li class="c-form-list__item o-layout__item u-width-1--m"> <span>
                        <input class="form-control form-control-sm col-sm-4 text-center float-right cart-quantity ctgyQuantity" style="margin:0 auto" type="tel" min="0" name="Quantity" value="1">
                        </span> </li>
                        <li class="c-form-list__item o-layout__item u-width-3--m">
                        <input type="submit" value="Add to Cart" class="ctgyCart c-button c-button--full c-button--huge c-control-group__button u-bg-primary u-color-black u-text-bold u-font-small u-text-uppercase">
                        </li>
                        </ul>
                        </form>
                        <hr class="c-keyline">
                        </section>
                        </mvt:foreach>
                        </mvt:foreach>
                        <mvt:assign name="l.settings:sub_categories2" value=" " />
                        </mvt:if>
                        </mvt:foreach>
                        </mvt:if>
                        My problem is with that "load first 100 products assigned to a specific category" - I don't want to load the first 100, I want to load exactly what is in the category. But it's what I was given to use to replace Toolkit code.
                        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


                          #13
                          That's exactly what I'm doing Leslie. I have what I've always used with Toolkit that I can use as a back up, but I'm trying to avoid that as this is way cooler.

                          I have a ticket open. They are saying obviously that goes beyond what they can handle, but they'll ask around. We'll have much better luck here with Bruce and co chiming in as they are able or maybe someone in house will take pitty on us today and help us out with this one haha. I've tried setting the offset's to null, I've tried all variations of functions. I've tried isolating what is actually assigned from what isn't and just not showing any product within each of the loops that aren't actually assigned to that category haha. None of it worked. This wants very badly to spit out the same # of categories once the "category with the most items in it" shows, then all after it must include that many items, even if it has to pull from those above. It is very odd indeed, but I bet the solution involves tweaking less than 20 characters in our code above haha.

                          May the fortune look fondly upon us Leslie :)
                          Ted Hust
                          AarcMediaGroup.com

                          Celebrating 13 Years of Outstanding Service & Support
                          Miva Merchant Design

                          Comment


                            #14
                            Ted, I sent you a PM.
                            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


                              #15
                              lesliekirk the FIX IS IN......

                              Simply add this.....

                              HTML Code:
                              <mvt:assign name="l.settings:myProducts" value="0" />
                              .....to the line just above Runtime_ProductList_Load_Offset_Category. And Boom, it works.
                              Ted Hust
                              AarcMediaGroup.com

                              Celebrating 13 Years of Outstanding Service & Support
                              Miva Merchant Design

                              Comment

                              Working...
                              X