Jump to content

Display products and hide xml response


Envox

Recommended Posts

Hello Guys,

Im starting in prestashop and this is my first project, Im doing ecommerce and usign webservice in this project;

I have 2 questions:

The First is:

I have this code in WS(webservice)...

    $opt[ 'resource' ] = 'products'; 
    $opt[ 'display' ] = 'full';
    $xml = $webService->get($opt);
    
    The $xml go return all information of the products, same this:
<products>
<product>
    <id><![CDATA[1]]></id>
    <id_manufacturer xlink:href="http://localhost/eco...manufacturers/1"><![CDATA[1]]></id_manufacturer>
    <id_supplier xlink:href="http://localhost/eco...api/suppliers/1"><![CDATA[1]]></id_supplier>
    <id_category_default xlink:href="http://localhost/eco...pi/categories/5"><![CDATA[5]]></id_category_default>
    <new></new>
........
 
<associations>
<categories nodeType="category" api="categories">
    <category xlink:href="http://localhost/eco...pi/categories/2">
    <id><![CDATA[2]]></id>
    </category>
    <category xlink:href="http://localhost/eco...pi/categories/3">
    <id><![CDATA[3]]></id>
    </category>
    <category xlink:href="http://localhost/eco...pi/categories/4">
    <id><![CDATA[4]]></id>
    </category>
    <category xlink:href="http://localhost/eco...pi/categories/5">
    <id><![CDATA[5]]></id>
    </category>
</categories>
<images nodeType="image" api="images">
    <image xlink:href="http://localhost/eco...es/products/1/1">
    <id><![CDATA[1]]></id>
    </image>
    <image xlink:href="http://localhost/eco...es/products/1/2">
    <id><![CDATA[2]]></id>
    </image>
    <image xlink:href="http://localhost/eco...es/products/1/3">
    <id><![CDATA[3]]></id>
    </image>
    <image xlink:href="http://localhost/eco...es/products/1/4">
    <id><![CDATA[4]]></id>
    </image>
</images>
 
 
Well, and now if I use this code:
    $opt[ 'resource' ] = 'products'; 
    $opt[ 'display' ] = '[id, name, description, id_default_image]';
    $xml = $webService->get($opt);
 
The $xml now go return only this information "id, nome, description e id_default_image":
 
My question is: How need more performance, How I do to return ONLY "id, nome, description, id_default_image", AND MORE ONLY the tag images, it are in tag <associations>.
Return same this:
<product>
    <id><![CDATA[8]]></id>
    <id_default_image xlink:href="http://localhost/eco...s/products/8/24" notFilterable="true"><![CDATA[24]]></id_default_image>
    <name></name>
    <description></description>
<associations>
<images nodeType="image" api="images">
    <image xlink:href="http://localhost/eco...es/products/1/1">
    <id><![CDATA[1]]></id>
    </image>
    <image xlink:href="http://localhost/eco...es/products/1/2">
    <id><![CDATA[2]]></id>
    </image>
    <image xlink:href="http://localhost/eco...es/products/1/3">
    <id><![CDATA[3]]></id>
    </image>
    <image xlink:href="http://localhost/eco...es/products/1/4">
    <id><![CDATA[4]]></id>
    </image>
</images>

 

 

THE MY SECOND QUESTION IS:

This line code "$webService->get($opt);" will return a background gray with informations in xml, How I do for hide this return xml?:

HTTP REQUEST HEADER
GET /ecommerce/prestashop/api/products?display=%5Bid%2C+name%2C+description%2C+id_default_image%5D HTTP/1.1Authorization: Basic Nks3WFg4NjRQQUs4SEpLWkJCRDNVUVpFNTNKMTlJN1Q6Host: localhostAccept: */*
HTTP RESPONSE HEADER
HTTP/1.1 200 OKDate: Mon, 06 Jul 2015 15:08:42 GMTServer: Apache/2.4.9 (Win64) PHP/5.5.12X-Powered-By: PrestaShop WebserviceAccess-Time: 1436195323PSWS-Version: 1.6.0.14Execution-Time: 0.096Content-Sha1: 545e6385ecb8eef716d00cc9ff4adc22df581759Transfer-Encoding: chunkedContent-Type: text/xml;charset=utf-8
RETURN HTTP BODY

 

 

 

Thx... and sorry to my bad english

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