Announcement

Collapse
No announcement yet.

Related Products - Sort By / Custom Fields

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

    Related Products - Sort By / Custom Fields

    Can sorting by a custom field within Related Products be done, if so, how?

    I was checking the forum posts but could not find an answer. I did see Brennan had posted the below here.


    There is nothing built in to sort by a custom field, but you can do it with some template code.

    You'll first need to add the custom field the products array so you can later sort on it. This code should go above your category product list loop.
    Code:
      
    <mvt:foreach iterator="product" array="category_listing:products">
    
             <mvt:assign name="g.brand" value="''" />
             <mvt:item name="customfields" param="Read_Product_Code( l.settings:product:code, 'brand', g.brand )" />
                      <mvt:if expr="NOT ISNULL g.brand">        
                               <mvt:assign name="l.settings:product:brand" value="g.brand" />    
                      </mvt:if>  
    
    </mvt:foreach>  
    
    <mvt:if expr="g.Sort_By EQ 'Brand'">    
             <mvt:do file="g.module_library_utilities" name="l.null" value="QuickSortArray(l.settings:products, '', 1)" />
    </mvt:if>
    Thanks in advance.

    #2
    Related products are just a product listings, you just need change the array of the code above (oh, I think the ' ' in the QuickSortArray() function should be g.brand.
    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
      I want to know it, too. Did you get it?

      Comment

      Working...
      X