Skip to main content
added 166 characters in body; edited title
Source Link
Bako Gdaniec
  • 169
  • 1
  • 2
  • 15

Update product programatically (setDescription) Error Object of class stdClass could not be converted to string

Hello I would like to set the Description for magento products using data collected from Amazon api. I am calling the API and would like to get the xml response into magento description. I have some code prepared which works:

<?php
 require('../AmazonApi.php');
 require_once ('../app/Mage.php');
 Mage::app();

 //Create API access object
 $public_key = '*************';
 $secret_key = '*************';
 $associate_tag = '**********-21';
 $amazon_api = new AmazonAPI($public_key, $secret_key, $associate_tag);


$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('asin')
->addAttributeToSelect('description');

//Array of request parameters
foreach($products as $product)
{
$asin = $product->getAsin();
$product->setDescription($response);
$product->getResource()->saveAttribute($product, 'description');
$params_array = array(
'Operation' => 'ItemLookup',
'IdType' => 'ASIN',
'ItemId' => $asin ,
'ResponseGroup' => 'Tracks');

// returns a list of items for the search query 'Slow Magic'
$response = $amazon_api->sendRequest($params_array);

foreach ($response as $restponse)
{
sleep(1);
}

echo '<pre>';
print_r($response);
echo '</pre>';
}

foreach($parsed_xml->OperationRequest->Errors->Error as $error){
 echo "Error code: " . $error->Code . "\r\n";
 echo $error->Message . "\r\n";
 echo "\r\n";
 }

The code is correct the only problem with is the response, the error I am getting the data by callingin the api however it doesn't save it into magento product description.logs is:

Object of class stdClass could not be converted to string Object of class stdClass could not be converted to string.

Any how to convert to a string?

Update product programatically (setDescription)

Hello I would like to set the Description for magento products using data collected from Amazon api. I am calling the API and would like to get the xml response into magento description. I have some code prepared :

<?php
 require('../AmazonApi.php');
 require_once ('../app/Mage.php');
 Mage::app();

 //Create API access object
 $public_key = '*************';
 $secret_key = '*************';
 $associate_tag = '**********-21';
 $amazon_api = new AmazonAPI($public_key, $secret_key, $associate_tag);


$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('asin')
->addAttributeToSelect('description');

//Array of request parameters
foreach($products as $product)
{
$asin = $product->getAsin();
$product->setDescription($response);
$product->getResource()->saveAttribute($product, 'description');
$params_array = array(
'Operation' => 'ItemLookup',
'IdType' => 'ASIN',
'ItemId' => $asin ,
'ResponseGroup' => 'Tracks');

// returns a list of items for the search query 'Slow Magic'
$response = $amazon_api->sendRequest($params_array);

foreach ($response as $restponse)
{
sleep(1);
}

echo '<pre>';
print_r($response);
echo '</pre>';
}

foreach($parsed_xml->OperationRequest->Errors->Error as $error){
 echo "Error code: " . $error->Code . "\r\n";
 echo $error->Message . "\r\n";
 echo "\r\n";
 }

I am getting the data by calling the api however it doesn't save it into magento product description.

Update product programatically (setDescription) Error Object of class stdClass could not be converted to string

Hello I would like to set the Description for magento products using data collected from Amazon api. I am calling the API and would like to get the xml response into magento description. I have some code prepared which works:

<?php
 require('../AmazonApi.php');
 require_once ('../app/Mage.php');
 Mage::app();

 //Create API access object
 $public_key = '*************';
 $secret_key = '*************';
 $associate_tag = '**********-21';
 $amazon_api = new AmazonAPI($public_key, $secret_key, $associate_tag);


$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('asin')
->addAttributeToSelect('description');

//Array of request parameters
foreach($products as $product)
{
$asin = $product->getAsin();
$product->setDescription($response);
$product->getResource()->saveAttribute($product, 'description');
$params_array = array(
'Operation' => 'ItemLookup',
'IdType' => 'ASIN',
'ItemId' => $asin ,
'ResponseGroup' => 'Tracks');

// returns a list of items for the search query 'Slow Magic'
$response = $amazon_api->sendRequest($params_array);

foreach ($response as $restponse)
{
sleep(1);
}

echo '<pre>';
print_r($response);
echo '</pre>';
}

foreach($parsed_xml->OperationRequest->Errors->Error as $error){
 echo "Error code: " . $error->Code . "\r\n";
 echo $error->Message . "\r\n";
 echo "\r\n";
 }

The code is correct the only problem with is the response, the error I am getting in the logs is:

Object of class stdClass could not be converted to string Object of class stdClass could not be converted to string.

Any how to convert to a string?

added 22 characters in body
Source Link
Bako Gdaniec
  • 169
  • 1
  • 2
  • 15

Hello I would like to set the Description for magento products using data collected from Amazon api. I am calling the API and would like to get the xml response into magento description. I have some code prepared :

<?php
 require('../AmazonApi.php');
 require_once ('../app/Mage.php');
 Mage::app();

 //Create API access object
 $public_key = '*************';
 $secret_key = '*************';
 $associate_tag = '**********-21';
 $amazon_api = new AmazonAPI($public_key, $secret_key, $associate_tag);


$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSeleXct>addAttributeToSelect('asin')
->addAttributeToSelect('description')
->load($productId);

//Array of request parameters
foreach($products as $product)
{
$asin = $product->getAsin();
$product->setDescription($response);
$product->save>getResource()->saveAttribute($product, 'description');
$params_array = array(
'Operation' => 'ItemLookup',
'IdType' => 'ASIN',
'ItemId' => $asin ,
'ResponseGroup' => 'Tracks');

// returns a list of items for the search query 'Slow Magic'
$response = $amazon_api->sendRequest($params_array);

foreach ($response as $restponse)
{
sleep(1);
}

echo '<pre>';
print_r($response);
echo '</pre>';
}

foreach($parsed_xml->OperationRequest->Errors->Error as $error){
 echo "Error code: " . $error->Code . "\r\n";
 echo $error->Message . "\r\n";
 echo "\r\n";
 }

I am getting the data by calling the api however it doesn't save it into magento product description.

Hello I would like to set the Description for magento products using data collected from Amazon api. I am calling the API and would like to get the xml response into magento description. I have some code prepared :

<?php
 require('../AmazonApi.php');
 require_once ('../app/Mage.php');
 Mage::app();

 //Create API access object
 $public_key = '*************';
 $secret_key = '*************';
 $associate_tag = '**********-21';
 $amazon_api = new AmazonAPI($public_key, $secret_key, $associate_tag);


$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSeleXct('asin')
->addAttributeToSelect('description')
->load($productId);

//Array of request parameters
foreach($products as $product)
{
$asin = $product->getAsin();
$product->setDescription($response);
$product->save();
$params_array = array(
'Operation' => 'ItemLookup',
'IdType' => 'ASIN',
'ItemId' => $asin ,
'ResponseGroup' => 'Tracks');

// returns a list of items for the search query 'Slow Magic'
$response = $amazon_api->sendRequest($params_array);

foreach ($response as $restponse)
{
sleep(1);
}

echo '<pre>';
print_r($response);
echo '</pre>';
}

foreach($parsed_xml->OperationRequest->Errors->Error as $error){
 echo "Error code: " . $error->Code . "\r\n";
 echo $error->Message . "\r\n";
 echo "\r\n";
 }

I am getting the data by calling the api however it doesn't save it into magento product description.

Hello I would like to set the Description for magento products using data collected from Amazon api. I am calling the API and would like to get the xml response into magento description. I have some code prepared :

<?php
 require('../AmazonApi.php');
 require_once ('../app/Mage.php');
 Mage::app();

 //Create API access object
 $public_key = '*************';
 $secret_key = '*************';
 $associate_tag = '**********-21';
 $amazon_api = new AmazonAPI($public_key, $secret_key, $associate_tag);


$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('asin')
->addAttributeToSelect('description');

//Array of request parameters
foreach($products as $product)
{
$asin = $product->getAsin();
$product->setDescription($response);
$product->getResource()->saveAttribute($product, 'description');
$params_array = array(
'Operation' => 'ItemLookup',
'IdType' => 'ASIN',
'ItemId' => $asin ,
'ResponseGroup' => 'Tracks');

// returns a list of items for the search query 'Slow Magic'
$response = $amazon_api->sendRequest($params_array);

foreach ($response as $restponse)
{
sleep(1);
}

echo '<pre>';
print_r($response);
echo '</pre>';
}

foreach($parsed_xml->OperationRequest->Errors->Error as $error){
 echo "Error code: " . $error->Code . "\r\n";
 echo $error->Message . "\r\n";
 echo "\r\n";
 }

I am getting the data by calling the api however it doesn't save it into magento product description.

Source Link
Bako Gdaniec
  • 169
  • 1
  • 2
  • 15

Update product programatically (setDescription)

Hello I would like to set the Description for magento products using data collected from Amazon api. I am calling the API and would like to get the xml response into magento description. I have some code prepared :

<?php
 require('../AmazonApi.php');
 require_once ('../app/Mage.php');
 Mage::app();

 //Create API access object
 $public_key = '*************';
 $secret_key = '*************';
 $associate_tag = '**********-21';
 $amazon_api = new AmazonAPI($public_key, $secret_key, $associate_tag);


$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSeleXct('asin')
->addAttributeToSelect('description')
->load($productId);

//Array of request parameters
foreach($products as $product)
{
$asin = $product->getAsin();
$product->setDescription($response);
$product->save();
$params_array = array(
'Operation' => 'ItemLookup',
'IdType' => 'ASIN',
'ItemId' => $asin ,
'ResponseGroup' => 'Tracks');

// returns a list of items for the search query 'Slow Magic'
$response = $amazon_api->sendRequest($params_array);

foreach ($response as $restponse)
{
sleep(1);
}

echo '<pre>';
print_r($response);
echo '</pre>';
}

foreach($parsed_xml->OperationRequest->Errors->Error as $error){
 echo "Error code: " . $error->Code . "\r\n";
 echo $error->Message . "\r\n";
 echo "\r\n";
 }

I am getting the data by calling the api however it doesn't save it into magento product description.