Uploaded image for project: 'PrestaShop 1.7'
  1. PrestaShop 1.7
  2. BOOM-4554

Retrieving and showing the product in depth JSON values like product_option_values

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: All 1.7 versions
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Tests & Expected Results:
      N/A
    • Documentation Change:
      N/A

      Description

      Hi everyone,

      I've been building an application that creates some functionalities using the prestashop API. But after being able to show the products, customers, etc. I would like to get more detailed information from the products. Like the combinations, category's and option_values for showing the size and colours combinations. See the example JSON result below:

       NOTE: The application is build with angularJS, JSON responses and the prestashop webservice API.

       

       

      
       // code JSON response
       {"products":{"product":[{"id":"1","id_manufacturer":"1","id_supplier":"1","id_category_default":"5","new":{},"cache_default_attribute":"1","id_default_image":"1","id_default_combination":"1","id_tax_rules_group":"1","position_in_category":"0","manufacturer_name":"Fashion Manufacturer","quantity":"0","type":"simple","id_shop_default":"1","reference":"demo_1","supplier_reference":{},"location":{},"width":"0.000000","height":"0.000000","depth":"0.000000","weight":"0.000000","quantity_discount":"0","ean13":"333456789111","isbn":{},"upc":{},"cache_is_pack":"0","cache_has_attachments":"0","is_virtual":"0","state":"1","on_sale":"0","online_only":"0","ecotax":"0.000000","minimal_quantity":"1","price":"16.510000","wholesale_price":"4.950000","unity":{},"unit_price_ratio":"0.000000","additional_shipping_cost":"0.00","customizable":"0","text_fields":"0","uploadable_files":"0","active":"1","redirect_type":"404","id_type_redirected":"0","available_for_order":"1","available_date":"0000-00-00","show_condition":"0","condition":"new","show_price":"1","indexed":"1","visibility":"both","advanced_stock_management":"0","date_add":"2017-03-16 14:36:24","date_upd":"2017-12-01 13:01:13","pack_stock_type":"3","meta_description":{"language":{"@attributes":{"id":"1"}}},"meta_keywords":{"language":{"@attributes":{"id":"1"}}},"meta_title":{"language":{"@attributes":{"id":"1"}}},"link_rewrite":{"language":"gebleekte-T-shirts-met-korte-mouwen"},"name":{"language":"Gebleekte T-shirts met Korte Mouwen"},"description":{"language":" Fashion maakt goed ontworpen collecties sinds 2010. Het merk biedt vrouwelijke combineerbare kleding en statement dresses en heeft een pr\u00eat-\u00e0-porter collectie ontwikkeld met kledingstukken die niet in een garderobe mogen ontbreken. Het resultaat? Cool, gemakkelijk, easy, chique met jeugdige elegantie en een duidelijk herkenbare stijl. Alle prachtige kledingstukken worden met de grootste zorg gemaakt in Itali\u00eb. Fashion breidt zijn aanbod uit met accessoires zoals schoenen, hoeden, riemen!<\/p>"},"description_short":{"language":" Gebleekt T-shirt met korte mouwen en hoge halslijn. Zacht en elastisch materiaal zorgt voor een comfortabele pasvorm. Maak het af met een strooien hoed en u bent klaar voor de zomer!<\/p>"},"available_now":{"language":"Op voorraad"},"available_later":{"language":{"@attributes":{"id":"1"}}},"associations":{"categories":{"@attributes":{"nodeType":"category","api":"categories"},"category":[{"id":"2"},{"id":"3"},{"id":"4"},{"id":"5"}]},"images":{"@attributes":{"nodeType":"image","api":"images"},"image":[{"id":"1"},{"id":"2"},{"id":"3"},{"id":"4"}]},"combinations":{"@attributes":{"nodeType":"combination","api":"combinations"},"combination":[{"id":"1"},{"id":"2"},{"id":"3"},{"id":"4"},{"id":"5"},{"id":"6"}]},"product_option_values":{"@attributes":{"nodeType":"product_option_value","api":"product_option_values"},"product_option_value":[{"id":"1"},{"id":"13"},{"id":"14"},{"id":"2"},{"id":"3"}]},"product_features":{"@attributes":{"nodeType":"product_feature","api":"product_features"},"product_feature":[{"id":"5","id_feature_value":"5"},{"id":"6","id_feature_value":"11"},{"id":"7","id_feature_value":"17"}]},"tags":{"@attributes":{"nodeType":"tag","api":"tags"}},"stock_availables":{"@attributes":{"nodeType":"stock_available","api":"stock_availables"},"stock_available":[{"id":"1","id_product_attribute":"0"},{"id":"11","id_product_attribute":"1"},{"id":"12","id_product_attribute":"2"},{"id":"13","id_product_attribute":"3"},{"id":"22","id_product_attribute":"4"},{"id":"23","id_product_attribute":"5"},{"id":"24","id_product_attribute":"6"}]},"accessories":{"@attributes":{"nodeType":"product","api":"products"}},"product_bundle":{"@attributes":{"nodeType":"product","api":"products"}}}}

       

      As you can see above i'm showing one of the many products inside my response.

      Lets say that now i would like to show the product values. As in the combinations that create the size and colour possibilities. 

      I'm able to use the products table and the product_option_values table through the webservice to get the product_option_values id's and the value's name. But how would i be able to connect them together. Take a look at the example below.

      Using:

       

      <div class="col-lg-3" ng-repeat="value in products">
       <p ng-bind="value.associations.product_option_values.product_option_value"></p>
      </div>

       

      Gives the following result for each product its specific option_values.

       

      [{"id":"1"},{"id":"13"},{"id":"14"},{"id":"2"},{"id":"3"}]

       

      Now i would like to compare these to the option_values table to retrieve the option value name. In this case these are the id's. inside the table.

       

      {"product_option_values":{"product_option_value":[{"id":"1","id_attribute_group":"1","color":{},"position":"0","name":{"language":"S"}},{"id":"2","id_attribute_group":"1","color":{},"position":"1","name":{"language":"M"}},{"id":"3","id_attribute_group":"1","color":{},"position":"2","name":{"language":"L"}},{"id":"4","id_attribute_group":"1","color":{},"position":"3","name":{"language":"One size"}},{"id":"18","id_attribute_group":"2","color":{},"position":"0","name":{"language":"35"}},{"id":"19","id_attribute_group":"2","color":{},"position":"1","name":{"language":"36"}},{"id":"20","id_attribute_group":"2","color":{},"position":"2","name":{"language":"37"}},{"id":"21","id_attribute_group":"2","color":{},"position":"3","name":{"language":"38"}},{"id":"22","id_attribute_group":"2","color":{},"position":"4","name":{"language":"39"}},{"id":"23","id_attribute_group":"2","color":{},"position":"5","name":{"language":"40"}},{"id":"5","id_attribute_group":"3","color":"#AAB2BD","position":"0","name":{"language":"Grijs"}},{"id":"6","id_attribute_group":"3","color":"#CFC4A6","position":"1","name":{"language":"Taupe"}},{"id":"7","id_attribute_group":"3","color":"#f5f5dc","position":"2","name":{"language":"Beige"}},{"id":"8","id_attribute_group":"3","color":"#ffffff","position":"3","name":{"language":"Wit"}},{"id":"9","id_attribute_group":"3","color":"#faebd7","position":"4","name":{"language":"Gebroken wit"}},{"id":"10","id_attribute_group":"3","color":"#E84C3D","position":"5","name":{"language":"Rood"}},{"id":"11","id_attribute_group":"3","color":"#434A54","position":"6","name":{"language":"Zwart"}},{"id":"12","id_attribute_group":"3","color":"#C19A6B","position":"7","name":{"language":"Camel"}},{"id":"13","id_attribute_group":"3","color":"#F39C11","position":"8","name":{"language":"Oranje"}},{"id":"14","id_attribute_group":"3","color":"#5D9CEC","position":"9","name":{"language":"Blauw"}},{"id":"15","id_attribute_group":"3","color":"#A0D468","position":"10","name":{"language":"Groen"}},{"id":"16","id_attribute_group":"3","color":"#F1C40F","position":"11","name":{"language":"Geel"}},{"id":"17","id_attribute_group":"3","color":"#964B00","position":"12","name":{"language":"Bruin"}},{"id":"24","id_attribute_group":"3","color":"#FCCACD","position":"13","name":{"language":"Roze"}}]}}

       

      Now i would like to show the names of the option_values of each product. Like with product_id = 1 it would be:

      Small (S), Medium (m), Large (L), Blue (blauw), Orange (oranje). 

      So the corresponding name with the corresponding option_value_id.

       

      The problems i'm having is that i can't use an ng-if like

       

      <div class="row" ng-if="product.associations.product_option_values.product_option_value.id == productValue.id" ng-repeat-start="productValue in productValues">

       

      Since "option_value.id" results in NULL. and using the option without ".id" will always return 0 because it's still {id: "1", id: "3", etc.}

      The ultimate result i would like to create is an ng-repeat of buttons with each size and color. e.g.

      button 1: Small, blue

      button 2: Small, orange

      button 3: Medium, Blue

      button 4: Medium, orange

      etc.

      All from the correspondig id's for each product.

      The categories.

       

       

      **With all this sad. how would i achieve the same for a product filter on category id. I can only get to the category_default but that isn't the real place where the product is stated. Thats in the associations.category.categories : id values.

      I hope someone has a good answer since this issue affects a lot of functionallities inside the usage of the webservice. Thats why i also think this is a pretty big bug / critical issue.

      Thanks in advance!

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Deathstorm Niels van Enckevort
                Developer:
                Pablo Borowicz
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: