Announcement

Collapse
No announcement yet.

Product Page - pull products by custom product field?

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

    Product Page - pull products by custom product field?

    I've been looking around and I can't seem to find a solution to my problem.

    I want to be able to search for and return products by their custom product field. For example, we have a product that has a certain brand, as defined by a custom product field. Is there any way that I can pull ALL products of that brand, say, on the product page itself?

    And maybe perhaps combine the product fields? So I could pull all products of a specific brand, and say, a specific color, and display a list on the product page itself?

    Thanks.

    #2
    If you just want customers to use that field to search, enable the 'Facet' selection for that custom field and then add that custom field in the Search settings (under User Interface).

    Otherwise, if you just want a page of these products to appear you could 1) just add them to a category or two, create a custom display that used the Product_List_LoadAll() function with the output wrapped in a conditional to test for that field. Sort of like:

    Code:
    On site
    
    <form method="post" action="/thispage.html">
    <input type="hidden" name="doit" value="1"/>
    <input type="text" name="lookfor" value="&mvt:global:lookfor;"/>
    <button>Find It</button>
    </form>
    
    In the template:
    
    <mvt:if expr="g.goit">
    
    <mvt:do file="g.Module_Library_DB" name="l.success" value="Runtime_ProductList_Load_All(l.settings:the seProducts)" />
    
    <mvt:foreach iterator="product" array="theseproducts">
    
    <mvt:item name="customfields" param="Read_Product_Id( l.settings:product:id, 'the_custom_field_code', g.findthis)" />
    <mvt:if expr="tolower(g.lookfor) EQ tolowe(g.findthis)">
    &mvt:product:name;, &mvt:product:code;, etc <br />
    </mvt:if>
    
    </mvt:foreach>
    
    </mvt:if>
    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
      What I'm looking for is more of the ability to have something like a "suggested products" system - but it pulls all products that are in the same brand. Or the same brand, same color. Or the same brand, same color, same size, etc. It wouldn't be manipulated at all by the customer - it would be an automatic thing that displays on the product page.

      So you have a table of products. The products have the custom product field named brand, and I want to find all the products with the same brand and all those products' info available to manipulate.


      Let me see what I can do with your second example.

      Thanks!

      Comment


        #4
        Yea, you'd just dispense with the Form input and use the bottom section of code feeding it the custom field of the 'parent 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


          #5
          Right, that's what I'm thinking.

          Looks like it'll do what I need it to.

          Thank you!

          Comment


            #6
            Performance wise this won't be a decent solution.

            I've been looking for an excuse to get into module building anyway...

            Comment


              #7
              Not with a lot of products. One thought (without a module) is to create a 'workbench' page. And on that page (pseudo code),

              Lets say the custom field is called 'brand'

              Loop through all products.
              Get Custom Field Value (lets say its Bruce)
              Assign product to a hidden category (a category whose Parent category is inactive) whose code is "_Bruce"

              This page can be called on a schedule basis.

              Now, where you need the list of products

              Get the value of the custom field (Bruce)
              Then append '_' to it in a new variable, and use that code in the CxP function.

              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


                #8
                Miva Merchant has some other features that might work for you if you get a little creative. For instance, you could create a category for each brand, instead of using a custom field. Then, instead of looping through every product in the store, you could just pull in all the products from the category.

                Another possibility is to create a Navigation Set for each brand, although that could get tedious if you have to do it by hand for a large number of products.

                Also, as it happens, I have a utility module that lets you write your own SELECT queries using template code. With that, you could do one query to get the custom field ID, and then a second query with a JOIN to pull in the products that have the desired value in the field. You can PM or email me if you're interested in that.

                Kent Multer
                Magic Metal Productions
                http://TheMagicM.com
                * Web developer/designer
                * E-commerce and Miva
                * Author, The Official Miva Web Scripting Book -- available on-line:
                http://www.amazon.com/exec/obidos/IS...icmetalproducA

                Comment


                  #9
                  Thanks for your help guys! I'll fiddle around with some of these suggestions and I'll see what I can do.

                  Appreciate ya'll!

                  Comment

                  Working...
                  X