Jump to content

Update Product via API removes images


AdrianoMaia

Recommended Posts

Hello, 

I've the following difficulty: I'm using the API to send products. When I use the PUT request - to update data - the images in my website disappear. They are in the admin (backend). I've to manually save the product for them to show. 

This is my xml: 
 

<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
    <product>
        <id><![CDATA[74]]></id>
        <id_manufacturer>0</id_manufacturer>
        <id_supplier>0</id_supplier>
        <id_category_default><![CDATA[42]]></id_category_default>
        <id_shop_default>1</id_shop_default>
        <type>simple</type>
        <state>1</state>
        <reference>CLMOSAICO/2.5</reference>
        <minimal_quantity><![CDATA[1]]></minimal_quantity>
        <low_stock_threshold><![CDATA[0]]></low_stock_threshold>
        <price><![CDATA[107]]></price>
        <active>1</active>
        <available_for_order>1</available_for_order>
        <show_price>1</show_price>
        <visibility>both</visibility>
        <meta_description>
            <language id="1" xlink:href="https://algolinho.slz.pt/api/languages/1"></language>
        </meta_description>
        <meta_keywords>
            <language id="1" xlink:href="https://algolinho.slz.pt/api/languages/1"></language>
        </meta_keywords>
        <meta_title>
            <language id="1"></language>
        </meta_title>
        <name>
            <language id="1">
                <![CDATA[Test Mosaico]]>
            </language>
        </name>
        <description>
            <language id="1">
                 <![CDATA[TEST TEXT]]>
            </language>
        </description>
        <description_short>
            <language id="1">
                <![CDATA[Test 250X270]]>
            </language>
        </description_short>
        <associations>
            <categories nodeType="category" api="categories">
                <category>
                    <id>2</id>
                </category>
                <category>
                    <id>42</id>
                </category>
                 <category >
                    <id>49</id>
                </category>
            </categories>
            <images><image xlink:href='https://mywebsite.pt/api/images/products/74/14'><id><![CDATA[14]]></id></image><image xlink:href='https://mywebsite.pt/api/images/products/74/15'><id><![CDATA[15]]></id></image></images>
            <product_option_values nodeType="product_option_value" api="product_option_values">
                <product_option_value><id>54</id></product_option_value> <product_option_value><id>16</id></product_option_value> <product_option_value><id>25</id></product_option_value>
            </product_option_values>
        </associations>
    </product>
</prestashop>

I attach some images for a better understanding 

2021_07_29_12_46_19_tt_Mosaico.png

tt2.png

tt3.png

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...

<link_rewrite>

<language id="1" xlink:href="shop/api/languages/1">

<![CDATA[]]></language><language id="2" xlink:href="https://shop/api/languages/2">

<![CDATA[]]></language><language id="3" xlink:href="https://shop/api/languages/3">

<![CDATA[]]></language><language id="4" xlink:href="https://shop/api/languages/4">

<![CDATA[]]></language><language id="6" xlink:href="https://shop/api/languages/6">

<![CDATA[]]></language></link_rewrite>

</link_rewrite>

The problem was coming from here the object above you have to assign it in your put request correctly (get the product and assign it to the new data.

Link to comment
Share on other sites

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...