Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>1. Is the code above correct and it's just Magento's API script is very slow?</strong></p> <p>Your code is correct, but the script is slow because (a) the SOAP API is not blazingly fast and (b) you are doing seperate calls for every single product.</p> <p><strong>2. Is the code above not the best way of doing what I need?</strong></p> <p>If you use the SOAP v1 API or XML-RPC, you can <strong>test <a href="http://www.magentocommerce.com/wiki/doc/webservices-api/introduction">multiCall</a></strong>. At first, call catalog_category.assignedProducts to fetch the product ids. Collect the product ids and execute a multiCall call. That should cut the waiting time down quite a bit.</p> <p>Unfortunately, Magento doesn't provide a nice solution out of the box to deliver the data like you need it. I recommend that you <strong>implement your own custom API call</strong>.</p> <p>Use a product collection model:</p> <pre><code>$collection = Mage::getModel('catalog/product')-&gt;getCollection(); </code></pre> <p>This will get you a Mage_Catalog_Model_Resource_Product_Collection object which can be used to filter, sort, paginate, ... your product list. Iterate over the collection and build an array containing the data you need. You also can generate thumbnails for your products directly while building the data array:</p> <pre><code>foreach ($products as $product) { $data[$product-&gt;getSku()] = array( /* the attributes no need ... */ 'small_image' =&gt; Mage::helper('catalog/image')-&gt;init($product, 'image') -&gt;constrainOnly(true) -&gt;keepAspectRatio(true) -&gt;keepFrame(false) -&gt;resize(100,150) -&gt;__toString(), /* some more attributes ... */ ); } </code></pre> <p>This should give you quite a performance improvement.</p> <p>But of course this only is the <strong>tip of the iceberg</strong>. If this solution is not fast enough for you, avoid SOAP and bypass a part of the Magento stack by building <strong>your own API</strong>. This doesn't have to be a complex solution: it could be a simple PHP script with HTTP Basic Authentication which parses the URL for filter criteria etc., includes app/Mage.php and calls Mage::app() to initialise the Magento framework. The benefit is that you have the comfort of using Magento classes but you don't have to go through the whole routing process.</p> <p>Not to forget, you may <strong>cache the results</strong> because I could imagine that you will show the same products to quite a few visitors on the other domain. Even caching for a few minutes may help your server.</p> <p><strong>3. Could there be any other factors making this go so slow?</strong></p> <p>There may be some reasons why the calls are <em>that</em> slow on your server - but without knowing the volume of your data, your server hardware and the customisations you have done, even a best guess won't be that good.</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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