Announcement

Collapse
No announcement yet.

Obtaining a particular value of a product

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

    Obtaining a particular value of a product

    I have defined a new variable called "ProductColour" that holds the colour of a product in a form of a list with three choices (a) caramel, (b) brown, (c) black.

    Now I want to to obtain the colour of a particular product using its unique ID number. For example in plain English:

    Display the colour of product with ProductID number == 25.

    What's the right syntax please for expressing this?
    www.grafea.co.uk
    Vintage Leather briefcases

    http://www.grafea.com
    Designer leather bags
    --------------------------
    Yanni Kioupouroglou

    #2
    I think you will need to query the database directly to do this.
    Here is an example modified from another forum post some time back that returns the product image for the ProductID. (CVs are a bit more complex as they are not in the same table)

    You will need to look at the database and create a query to access the data you want then insert that into the function below for the query. (I would suggest developing the query in MS Access first and then copying the tested SQL query from there)

    Then add the modified function to the end of actinic_main.php and restart Actinic.

    Make sure you backup very well first.

    Code:
        function GetImage($prodid)
        {
           
            global $answer;
           
            $connect = odbc_connect("ActinicCatalog9","","");
           
            $query = "SELECT [Image FileName] FROM [product] WHERE [Product Reference]='".$prodid."'";
            $result = odbc_exec($connect, $query);
            while(odbc_fetch_row($result)){
                $answer = odbc_result($result, 1);
            }
            odbc_close($connect);
           
            return $answer;
        }

    Comment


      #3
      Thank you. Can i just double check that if I want to get the colour of the product, basically I use the code below and modify the line:


      $query = "SELECT [Image FileName] FROM [product] WHERE [Product Reference]='".$prodid."'";

      and change the SELECT [Image FileName] to "SELECT [ProductColour] ?

      Now if i want to use the value I obtain from this php function how to I incorporate this inside a <block if> tag ? in order to say:


      if ProductColour == "caramel" then go to section 48
      www.grafea.co.uk
      Vintage Leather briefcases

      http://www.grafea.com
      Designer leather bags
      --------------------------
      Yanni Kioupouroglou

      Comment


        #4
        No - not so simple.

        The colour (or selection reference index perhaps) you want which is the value of the custom variable is not in the same table as the productID hence the query will be different, and a bit more complex.

        You will call the function in Actinic in this manner:

        Code:
        <actinic:block php="true">
        GetImage("MyProductID");
        </actinic:block>
        To do this you will need knowledge of MS Access queries as well as knowledge of the Actinic database. You will need to open the Actinic database with Access and look at the linking IDs in the tables to be able to create the query.

        Comment


          #5
          Thanks again...I think this is a bit more than I can chew really.
          Now, trying to achieve this differently, is there a way of going directly to a section using the SectionID variable.

          e.g <a href=".....something with SectionID.....">My link</a>

          So when you click on "My link" you go directly to a specific section ?
          www.grafea.co.uk
          Vintage Leather briefcases

          http://www.grafea.com
          Designer leather bags
          --------------------------
          Yanni Kioupouroglou

          Comment


            #6
            It might be better if you just explained what you're trying to do.

            Mike
            -----------------------------------------

            First Tackle - Fly Fishing and Game Angling

            -----------------------------------------

            Comment


              #7
              Untested, but you should be able to use this to do that...

              Code:
                  function GetSectionPageURL($sectionID)
                  {
                     
                      global $answer;
                     
                      $connect = odbc_connect("ActinicCatalog9","","");
                     
                      $query = "SELECT [sPageName] FROM [Catalog section] WHERE [Catalogue section sequence]='".$sectionID."'";
                      $result = odbc_exec($connect, $query);
                      while(odbc_fetch_row($result)){
                          $answer = odbc_result($result, 1);
                      }
                      odbc_close($connect);
                     
                      return $answer;
                  }
              Code:
              <a href="<actinic:block php="true">
              $sPage = GetSectionPageURL("<actinic:variable encoding="perl" name="SectionID" selectable="false" />");
              echo $sPage;
              </actinic:block>
              ">MyLink<a/>

              Comment


                #8
                Underneath every product I've got some colour bars representing the available colour options that this item comes in.

                So e.g for a product leather briefcase I have a caramel, brown and black colour bar. I want to make these colour bars links so if a customer clicks on e.g a black bar, he goes directly to the section with the black briefcase. I can manually write the page link for every colour bar but thought perhaps easier to work with section ids.

                See attached photo
                Attached Files
                www.grafea.co.uk
                Vintage Leather briefcases

                http://www.grafea.com
                Designer leather bags
                --------------------------
                Yanni Kioupouroglou

                Comment


                  #9
                  Originally posted by Yanni View Post
                  Underneath every product I've got some colour bars representing the available colour options that this item comes in.

                  So e.g for a product leather briefcase I have a caramel, brown and black colour bar. I want to make these colour bars links so if a customer clicks on e.g a black bar, he goes directly to the section with the black briefcase. I can manually write the page link for every colour bar but thought perhaps easier to work with section ids.

                  See attached photo
                  If those colours where choices and you had linked those choices to the relevant products then you can get the productID from the variable <actinic:variable name="AssociatedProduct::ProductID" />. You can use this as the productid in the PHP code to find the section for that product and generate a link directly to it.

                  Malcolm

                  SellerDeck Accredited Partner,
                  SellerDeck 2016 Extensions, and
                  Custom Packages

                  Comment


                    #10
                    Already on the Community. Did you try searching?
                    Searching for "query database for variable" or "Getting User Variable from Database" got me to http://community.actinic.com/archive...p/t-49736.html
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #11
                      Originally posted by malbro View Post
                      If those colours where choices and you had linked those choices to the relevant products...
                      The problem with choices is that they do not create a unique product section with its own html address thus i don't want to go down that route. I think the obvious option is to brush up on php and go that way or alternatively add the page address of every colour choice product manually.
                      www.grafea.co.uk
                      Vintage Leather briefcases

                      http://www.grafea.com
                      Designer leather bags
                      --------------------------
                      Yanni Kioupouroglou

                      Comment


                        #12
                        The way you do it is you create the unique products in their own section /page ( html address). Then you create the parent product that has the colour bands / links and create the product options for that. Then you associate one of the unique products with each choice and that's it.

                        The way you're doing it there's no sensible way to link the unique products with the parent. Actinic does this for you if you use the options /choices settings.

                        Mike
                        -----------------------------------------

                        First Tackle - Fly Fishing and Game Angling

                        -----------------------------------------

                        Comment


                          #13
                          Mike, I'm wondering what you're suggesting works well on the product level. However if i want to display these colour bands on section level, I cannot do this your own way. Have you checked the attached photo I have uploaded to show what I am trying to create. If you still think this is possible your way, I will give it a try.
                          www.grafea.co.uk
                          Vintage Leather briefcases

                          http://www.grafea.com
                          Designer leather bags
                          --------------------------
                          Yanni Kioupouroglou

                          Comment


                            #14
                            If you have a variable setting the colour against each product, you can run a block on the product list to group all of those products into sections of 'like' products. You could have three master sections, using a block in each, with each one filtering on the 3 different possible entries in your variable. It's a great way of getting actinic to create auto lists filtering on one or more filters.

                            Comment


                              #15
                              Sorry, I think I must have missed your image. Maybe the product choices isn't the best way to do it.

                              It looks to me as if what you're trying to do is essentially show the section image and then 'list' all the products inside that section underneath the image. In this case the 'list' is to be displayed as a number of colour bars representing the colour of each product in the section.

                              This sounds like something that will have been done before (although maybe not exactly the same). Your best bet is to follow the advice of Duncan and Norman (and Lee). They all know what they're doing in this area.

                              Mike
                              -----------------------------------------

                              First Tackle - Fly Fishing and Game Angling

                              -----------------------------------------

                              Comment

                              Working...
                              X