In Magento, what is the rest / products api extension performance to get tags and product attributes in a returned list?

The only way I can do this is to get the products, and then call the other APIs in the script to get the information I need before finally returning the answer.

I'm still a little new to Magento, and it seems to be pretty heavy in performance. Is the solution above efficient in performance, or is there a better way to get tags, etc. From the rest / api products?

Essentially, what I'm looking for is something like that:

The current API returns:

{
337: {
    entity_id: "337"
    type_id: "simple"
    sku: "ace000"
    color: "15"
    gender: "93"
    material: "130"
    jewelry_type: null
    description: "Gunmetal frame with crystal gradient polycarbonate lenses in grey. "
    meta_keyword: null
    short_description: "A timeless accessory staple, the unmistakable teardrop lenses of our Aviator sunglasses appeal to everyone from suits to rock stars to citizens of the world."
    name: "Aviator Sunglasses"
    meta_title: null
    meta_description: null
    regular_price_with_tax: 319.34
    regular_price_without_tax: 295
    final_price_with_tax: 319.34
    final_price_without_tax: 295
    is_saleable: true
    image_url: "http://magentogs.cloudapp.net/magento/media/catalog/product/cache/0/image/9df78eab33525d08d6e5fb8d27136e95/a/c/ace000a_1.jpg"
    }
}

I want to add the following (as an example) ** include things that show the things I want to add.

{
337: {
    entity_id: "337"
    type_id: "simple"
    sku: "ace000"
    color: "15"
    gender: "93"
    material: "130"
    jewelry_type: null
    description: "Gunmetal frame with crystal gradient polycarbonate lenses in grey. "
    meta_keyword: null
    short_description: "A timeless accessory staple, the unmistakable teardrop lenses of our Aviator sunglasses appeal to everyone from suits to rock stars to citizens of the world."
    name: "Aviator Sunglasses"
    meta_title: null
    meta_description: null
    regular_price_with_tax: 319.34
    regular_price_without_tax: 295
    final_price_with_tax: 319.34
    final_price_without_tax: 295
    is_saleable: true
    image_url: "http://magentogs.cloudapp.net/magento/media/catalog/product/cache/0/image/9df78eab33525d08d6e5fb8d27136e95/a/c/ace000a_1.jpg"
    **tags: [tag1,tag2,tag3]**
    **categories: [category1,category2,category3]**
    }
}
+4
1

REST- REST _prepareProductForResponse,

http://web.archive.org/web/20130512072025/http://magepim.com/news/Extending-the-Magento-REST-API-part-1_13

:

Namespace_yourmodule_Model_Catalog_Api2_Product_Rest extends Mage_Catalog_Model_Api2_Product_Rest {


protected function _prepareProductForResponse(Mage_Catalog_Model_Product $product)
{
 // keep the existing code as it is

 // now add new code to add tags

 $productData['tags'] = Mage::getModel('tag/tag')->getResourceCollection()
    ->addPopularity()
    ->addProductFilter($product->getId());


// in the end 
 $product->addData($productData);
}
+4

All Articles