Announcement

Collapse
No announcement yet.

Showing Dealers List from Customer List Where Custom Field is "dealer" (Yes/No)

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

    Showing Dealers List from Customer List Where Custom Field is "dealer" (Yes/No)

    Hello,

    I have a "Dealers" page but cannot successfully list my Dealers from the Customer Database, where I have a custom yes/no field: "dealer".

    Numerous iterations / combinations of code don't seem to work. I'm thinking the array is incorrect but am not able to find examples of customer arrays in Docs. Here's the latest code sample and I'm hoping a "good eye" might help me with it.

    Code:
    <mvt:item name="customfields" param="Read_Customer_ID( 'customer_id', 'dealer' )" />
    <mvt:item name="customfields" param="Read_Customer_ID( 'customer_id', 'dealer_website' )" />
    
    <mvt:foreach iterator="customer" array="all_customers:customers">
        <mvt:if expr="l.settings:customer:customfields:dealer EQ 1">
            &mvte:customer:ShipCompany;<br />
            &mvte:customer:customfields:dealer_website;<br />
            &mvte:customer:ShipPhone;
        </mvt:if>
    </mvt:foreach>
    Many thanks in advance.
    Michael



    #2
    The custom field calls need to be inside the foreach

    Code:
     
     <mvt:item name="customfields" param="Read_Customer_ID( 'customer_id', 'dealer' )" /> <mvt:item name="customfields" param="Read_Customer_ID( 'customer_id', 'dealer_website' )" />  <mvt:foreach iterator="customer" array="all_customers:customers">    <mvt:item name="customfields" param="Read_Customer_ID( l.settings:all_customers:customers:customer_id, 'dealer' )" />     <mvt:item name="customfields" param="Read_Customer_ID( l.settings:all_customers:customers:, 'dealer_website' )" />      <mvt:if expr="l.settings:customer:customfields:dealer EQ 1">         &mvte:customer:ShipCompany;<br />         &mvte:customer:customfields:dealer_website;<br />         &mvte:customer:ShipPhone;     </mvt:if> </mvt:foreach>
    and the customer_id needs to be a variable not a literial

    l.settings:all_customers:customers:customer_id

    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
      Hi Bruce,

      Many thanks for your reply.

      I've edited that code with your corrections yet I still have troubles with anything showing on this page. "customfields" and "customer" are checked as Items as well. Here it is again:

      Code:
       <mvt:foreach iterator="customer" array="all_customers:customers">    
       <mvt:item name="customfields" param="Read_Customer_ID( l.settings:all_customers:customers:customer_id, 'dealer' )" />
       <mvt:item name="customfields" param="Read_Customer_ID( l.settings:all_customers:customers:customer_id, 'dealer_website' )" />
          <mvt:if expr="l.settings:customers:customfields:dealer EQ 1">
                   &mvte:customer:ShipCompany;<br />
                   &mvte:customer:customfields:dealer_website;<br />
                   &mvte:customer:ShipPhone;
          </mvt:if> 
       </mvt:foreach>
      Still puzzled about this.

      Regards,
      Michael

      Comment


        #4
        How are you creating/calling the l.settings:all_customers:customers array?

        What happens when you enter &mvt:all_customers:customers; (you should see a whole boat load of data). Off hand, I don't know of a built in function that loads all customers (since that's only used on the admin side)

        (Also small error in logic, the read function is missing the output var)
        Code:
         
         <mvt:foreach iterator="customer" array="all_customers:customers">      <mvt:item name="customfields" param="Read_Customer_ID( l.settings:all_customers:customers:customer_id, 'dealer', l.settings:customers:customfields )" />  <mvt:item name="customfields" param="Read_Customer_ID( l.settings:all_customers:customers:customer_id, 'dealer_website', l.settings:customers:customfields)" />     <mvt:if expr="l.settings:customers:customfields:dealer EQ 1">              &mvte:customer:ShipCompany;<br />              &mvte:customer:customfields:dealer_website;<br />              &mvte:customer:ShipPhone;     </mvt:if>   </mvt:foreach>
        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
          You would need to load all customers yourself using this code:

          Code:
           <mvt:do file="g.Module_Feature_CUS_DB" name="l.success" value="CustomerList_Load_All(l.settings:customers)" />
          Then you can use the code you have above:

          Code:
              
          <mvt:foreach iterator="customer" array="customers"> 
          
              <mvt:item name="customfields" param="Read_Customer_ID( l.settings:customer:id, 'dealer' )" />  
              <mvt:item name="customfields" param="Read_Customer_ID( l.settings:customer:id, 'dealer_website' )" />    
          
              <mvt:if expr="l.settings:customfields:dealer EQ 1">             
                  &mvte:customer:ShipCompany;<br />             
                  &mvte:customer:customfields:dealer_website;<br />
                  &mvte:customer:ShipPhone;     
              </mvt:if>  
          
          </mvt:foreach>
          Keep in mind, this is an OK solution when you don't have a large number of customers. However, if your store has several hundred thousand customers, this page is loading all customers and then looping though them to display just the dealers. Once you start getting into a high number of customers, it is probably better to use a custom query to load just the data you need.
          Brennan Heyde
          VP Product
          Miva, Inc.
          [email protected]
          https://www.miva.com

          Comment


            #6
            LOL, literally just saw that function about 10 minutes ago in our own back end code and was going to post it.
            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


              #7
              Hi Bruce and Brennan, thanks for your replies.

              I have adopted that code but still no joy. All blank. Some thoughts:
              • Is there an Item one needs to assign for the mv:do?
              • This is a Page and not a customer-oriented page. Does that make a difference?

              cheers,
              Michael

              Comment

              Working...
              X