After adding product to Magento run http://mymagentohost/api/rest/products/40 it will return Resource not found but if just open product from Magento and click on save (without changing anything) than (run http://mymagentohost/api/rest/products/40) it will return product in xml view.

some code for saving product using REST OAuth as below

$this->productData = array( 
            'type_id' => 'activities',
            'attribute_set_id' => 4, 
            'sku' => 'activities' . uniqid(), 
            'status' => 1, 
            'visibility' => 4, 
            'name' => 'Activities Product',
            'description' => 'Activities Description', 
            'price' => 10.00,
            'sm_product_vendor_id' => 23,
            'category_id' => 1, 
            'tax_class_id' => 0, 

function saveProduct(){

try {
    $oauthClient = new OAuth($this->consumerKey, $this->consumerSecret, OAUTH_SIG_METHOD_HMACSHA1, $this->authType);
    $oauthClient->setToken($this->token, $this->secret);

    $headers =  array('Content-Type' => 'application/json');

    $oauthClient->fetch($this->resourceUrl, $this->productData, "POST", $headers);

    $this->responceInfo = $oauthClient->getLastResponseInfo();

    $this->responce = $oauthClient->getLastResponse();

} catch (OAuthException $e) {


Response Info

    [headers_recv] => HTTP/1.1 200 OK
    Date: Wed, 14 Aug 2013 03:15:59 GMT
    Server: Apache/2.2.22 (Win32) mod_ssl/2.2.22 OpenSSL/0.9.8o
    X-Powered-By: PHP/5.3.14 ZendServer
    Set-Cookie: ZDEDebuggerPresent=php,phtml,php3; path=/
    Set-Cookie: PHPSESSID=rrom4add03f0ikrt6d51ej9gi5; expires=Wed, 14-Aug-2013 04:16:00 GMT; path=/magento; domain=localhost; HttpOnly
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache

when i try to run http://mymagentohost/api/rest/products/40

it will return Resource not found

<magento_api><messages><error><data_item><code>404</code><message>Resource not found.</message></data_item></error></messages></magento_api>


while adding product via REST API following data not inserted in table (2 tables) . if i manually add following data in table than it will be retrieved via REST API. how to add this records using REST API

enter image description here magento_catalog_product_website
enter image description here

  • Confirmed on this table needs rows: magento_catalog_product_website .. and after that product/category index needed to be triggered.
    – jaywink
    Commented Apr 24, 2014 at 11:45

1 Answer 1


Was able to solve this by creating a custom REST API module that pretty much does this;

    $resource = Mage::getSingleton('core/resource');
    $writeConnection = $resource->getConnection('core_write');
    $table = $resource->getTableName('catalog/product_website');
    $query = "insert into {$table} values (" .$data['product_id']. ", 1)";

Replace 1 with website_id which is needed. I call this after saving the product as a separate API call. It could be inserted to the REST API in the core of course right after $product->save();

I did not find it necessary to add anything to magento_catalog_product_index_price

Pity Magento CE is not really open source so cannot do a pull request - it's more like "dumpsourceware".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.