Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <?php
  2. require('../AmazonApi.php');
  3. require_once ('../app/Mage.php');
  4. Mage::app();
  5.  
  6. //Create API access object
  7. $public_key = '*************';
  8. $secret_key = '*************';
  9. $associate_tag = '**********-21';
  10. $amazon_api = new AmazonAPI($public_key, $secret_key, $associate_tag);
  11.  
  12.  
  13. $products = Mage::getModel('catalog/product')
  14. ->getCollection()
  15. ->addAttributeToSelect('asin')
  16. ->addAttributeToSelect('description');
  17.  
  18. //Array of request parameters
  19. foreach($products as $product)
  20. {
  21. $asin = $product->getAsin();
  22. $product->setDescription($response);
  23. $product->getResource()->saveAttribute($product, 'description');
  24. $params_array = array(
  25. 'Operation' => 'ItemLookup',
  26. 'IdType' => 'ASIN',
  27. 'ItemId' => $asin ,
  28. 'ResponseGroup' => 'Tracks');
  29.  
  30. // returns a list of items for the search query 'Slow Magic'
  31. $response = $amazon_api->sendRequest($params_array);
  32.  
  33. foreach ($response as $restponse)
  34. {
  35. sleep(1);
  36. }
  37.  
  38. echo '<pre>';
  39. print_r($response);
  40. echo '</pre>';
  41. }
  42.  
  43. foreach($parsed_xml->OperationRequest->Errors->Error as $error){
  44. echo "Error code: " . $error->Code . "rn";
  45. echo $error->Message . "rn";
  46. echo "rn";
  47. }
  48.  
  49. $product->setDescription($response);
  50. $product->save();
  51.  
  52. $product->setDescription($response);
  53. $product->getResource()->saveAttribute($product, 'description')
  54.  
  55. $products = Mage::getModel('catalog/product')
  56. ->getCollection()
  57. ->addAttributeToSelect('asin')
  58. ->addAttributeToSelect('description')
  59. ->load($productId);
  60.  
  61. $products = Mage::getModel('catalog/product')
  62. ->getCollection()
  63. ->addAttributeToSelect('asin')
  64. ->addAttributeToSelect('description');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement