Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Magento API to get Products
    primarykey
    data
    text
    <p>I'm using the Magento API to get product data for products from a certain category from another domain. I have made the API call etc... The code I'm currently using to get the product data looks like this:</p> <pre><code>$productList = $client-&gt;call($session, 'catalog_category.assignedProducts', 7); foreach ($productList as $product){ $theProduct = array(); $theProduct['info'] = $client-&gt;call($session, 'catalog_product.info', $product['sku']); $allProducts[] = $theProduct; } </code></pre> <p>The code works fine, but it goes extremely slow. When I add the image call to the loop it takes about 50 seconds for the page to load, and that's for a site with only 5 products. What I want to know is the following:</p> <ol> <li>Is the code above correct and it's just Magento's API script is very slow?</li> <li>Is the code above not the best way of doing what I need?</li> <li>Could there be any other factors making this go so slow?</li> </ol> <p>Any help would be much appreciated. At least if I know I'm using the code right I can look at other avenues.</p> <p>Thanks in advance!</p> <p><strong>================= EDIT =================</strong></p> <p>Using multicall suggested by Matthias Zeis, the data arrives much quicker. Here's the code I used:</p> <pre><code>$apicalls = array(); $i = 0; $productList = $client-&gt;call($session, 'catalog_category.assignedProducts', 7); foreach ($productList as $product){ $apicalls[$i] = array('catalog_product.info', $product['product_id']); $i++; } $list = $client-&gt;multiCall($session, $apicalls); </code></pre> <p>This now works much quicker than before! The next issue I've found is that the <a href="http://www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_product_attribute_media#catalog_product_attribute_media.list">catalog_product_attribute_media.list</a> call doesn't seem to work in the same way, even though the products all have images set.</p> <p>The error I'm getting in the var_dump is:</p> <p><em><strong>Requested image not exists in product images' gallery.</em></strong></p> <p>Anybody know why this may now be happening? Thanks again in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload