Jump to content

Getting product customization values via webservice


samnorr

Recommended Posts

I am using a custom integration via the REST webservice, and I simply need a way to get the associated customization values for an order detail line. But I can't find any way of doing this from the documentation or anywhere else online.

 

I am able to get ALL historical customization values for a particular product by using /api/customizations endpoint, but there does not seem to be a way to relate the customized_data_text_field elements to a particular order line?

 

Would greatly appreciate any advice.

Link to comment
Share on other sites

  • 3 months later...
  • 1 year later...

Hey i have the same question, maybe samnorr find solution.

I need concrete customized_data_text_field value connected to concrete order.

gorgorbhey in api/customizations/NUMBER i have cart_id product_id customized_field and value BUT i have ALL values! Not only from cart_id.

When i bought this product twice in customizations/1 and customizations/2 i have TWO values connected to my product, but i need only one.

Link to comment
Share on other sites

  • 1 year later...

Hey everybody,

I'm experiencing the same issue. Ordering the same product several times with different customization fields, the listing in the order history looks like this:

grafik.png.2191de0cbd1aaaaff87457c64fbc3a11.png

So there were three different quantities with different customization fields. But requesting this information from the API is not distinguished as required.

Getting the customization fields using

*/api/customizations?filter[id_cart]=244

returns as expected three different customization ids:

<prestashop>
  <customizations>
    <customization id="215" xlink:href="*/api/customizations/215"/>
    <customization id="216" xlink:href="*/api/customizations/216"/>
    <customization id="217" xlink:href="*/api/customizations/217"/>
  </customizations>
</prestashop>

If we request the links provided in this xml file, the result is not clear.

api/customizations/215
--
leads to
--
...omitted...
<id>215</id>
...omitted...
<quantity>2</quantity>
...omitted...
<associations>
  <customized_data_text_fields nodeType="customized_data_text_field" virtualEntity="true">
    <customized_data_text_field>
      <id_customization_field xlink:href="*/api/product_customization_fields/27">27</id_customization_field>
      <value>FranzOhneMail</value>
    </customized_data_text_field>
    <customized_data_text_field>
      <id_customization_field xlink:href="*/api/product_customization_fields/28">28</id_customization_field>
      <value>[email protected]</value>
    </customized_data_text_field>
    <customized_data_text_field>
      <id_customization_field xlink:href="*/api/product_customization_fields/27">27</id_customization_field>
      <value>Hubert</value>
    </customized_data_text_field>
    <customized_data_text_field>
      <id_customization_field xlink:href="*/api/product_customization_fields/28">28</id_customization_field>
      <value>[email protected]</value>
    </customized_data_text_field>
  </customized_data_text_fields>
  <customized_data_images nodeType="customized_data_image" virtualEntity="true"/>
</associations>
...omitted...

And this is the same for each of the three requests, always containing all customized data text fields. The id and the quantity are correct, but you can't link the customization fields to the ids.

api/customizations/216
--
leads to
--
...omitted...
<id>216</id>
...omitted...
<quantity>3</quantity>
...omitted...
<associations>
  <customized_data_text_fields nodeType="customized_data_text_field" virtualEntity="true">
    <customized_data_text_field>
      <id_customization_field xlink:href="*/api/product_customization_fields/27">27</id_customization_field>
      <value>FranzOhneMail</value>
    </customized_data_text_field>
    <customized_data_text_field>
      <id_customization_field xlink:href="*/api/product_customization_fields/28">28</id_customization_field>
      <value>[email protected]</value>
    </customized_data_text_field>
    <customized_data_text_field>
      <id_customization_field xlink:href="*/api/product_customization_fields/27">27</id_customization_field>
      <value>Hubert</value>
    </customized_data_text_field>
    <customized_data_text_field>
      <id_customization_field xlink:href="*/api/product_customization_fields/28">28</id_customization_field>
      <value>[email protected]</value>
    </customized_data_text_field>
  </customized_data_text_fields>
  <customized_data_images nodeType="customized_data_image" virtualEntity="true"/>
</associations>
...omitted...

Does anybody know a solution for this?

Best regards
Fis8

Link to comment
Share on other sites

  • 1 month later...

Hi there,

I also experienced the same issue. There is a bug in Prestashop (at least here with 1.6.1).

In classes/Customization.php :

    public function getWsCustomizedDataTextFields()
    {
        if (!$results = Db::getInstance()->executeS('
            SELECT id_customization_field, value
            FROM `'._DB_PREFIX_.'customization_field` cf
            LEFT JOIN `'._DB_PREFIX_.'customized_data` cd ON (cf.id_customization_field = cd.index)
            WHERE `id_product` = '.(int)$this->id_product.' 
            AND cd.id_customization = '.(int)$this->id.' /* HERE IS THE MISSING PART */
            AND cf.type = 1')) {
            return array();
        }
        return $results;
    }

If you use customized data images, you have to also fix getWsCustomizedDataImages

Edited by Romain Lalaut (see edit history)
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...