Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. <?php
  2. class Macsanta_OnProductSave_Model_Observer {
  3. private function teest(){
  4. echo "string";
  5. }
  6. public function catalogProductSaveAfter(Varien_Event_Observer $observer)
  7. {
  8. $this->teest();
  9. $url = 'https://www.promoplace.com/ws/ws.dll/SITK';
  10. // $data = array('Request' => 'ProductDataDownload', 'APIVer' => 200, 'Auth' => array('AcctID' => '7496', 'Token' => '70ef35e852550f5f91b56cb3c2db8211' ), 'SAGENum' => 50681, 'Products' => array('NotPictured' => 0));
  11. //
  12.  
  13. // $data = [
  14. // "Request" => "ProductDataDownload",
  15. // "APIVer" => "200",
  16. // "Auth" => [
  17. // "AcctID" => 7496,
  18. // "Token" => "70ef35e852550f5f91b56cb3c2db8211"
  19. // ],
  20. // "SAGENum" => 50681,
  21. // "Products" => [
  22. // "ProductID" => 9180
  23. // ]
  24. // ];
  25. $data = [
  26. "Request" => "ProductDataDownload",
  27. "APIVer" => "200",
  28. "Auth" => [
  29. "AcctID" => 7496,
  30. "Token" => "70ef35e852550f5f91b56cb3c2db8211"
  31. ],
  32. "SAGENum" => 50681
  33. ];
  34. // use key 'http' even if you send the request to https://...
  35. $options = array(
  36. 'http' => array(
  37. 'header' => "Content-type: application/json\r\n",
  38. 'method' => 'POST',
  39. 'content' => json_encode($data)
  40. )
  41. );
  42. // var_dump($options);
  43. $context = stream_context_create($options);
  44. $result = file_get_contents($url, true, $context);
  45. if ($result === FALSE) { /* Handle error */ }
  46.  
  47. var_dump(json_decode($result));
  48. // Your ID and token
  49. // $authToken = '70ef35e852550f5f91b56cb3c2db8211';
  50. //
  51. // // The data to send to the API
  52. // $postData = json_encode($data);
  53. //
  54. // // Setup cURL
  55. // $ch = curl_init('https://www.promoplace.com/ws/ws.dll/SITK');
  56. // curl_setopt_array($ch, array(
  57. // CURLOPT_POST => TRUE,
  58. // CURLOPT_RETURNTRANSFER => TRUE,
  59. // CURLOPT_HTTPHEADER => array(
  60. // 'Authorization: '.$authToken,
  61. // 'Content-Type: application/json'
  62. // ),
  63. // CURLOPT_POSTFIELDS => json_encode($postData)
  64. // ));
  65. //
  66. // // Send the request
  67. // $response = curl_exec($ch);
  68. //
  69. // // Check for errors
  70. // if($response === FALSE){
  71. // die(curl_error($ch));
  72. // }
  73. //
  74. // // Decode the response
  75. // $responseData = json_decode($response, TRUE);
  76. //
  77. // // Print the date from the response
  78. // var_dump($responseData);
  79.  
  80.  
  81. // echo "hello";
  82. exit();
  83.  
  84. return $this;
  85. }
  86. // public function logUpdate(Varien_Event_Observer $observer)
  87. // {
  88. // $product = $observer->getEvent()->getProduct();
  89. // $name = $product->getName();
  90. // $sku = $product->getSku();
  91. //
  92. // Mage::log("{$name} ({$sku}) updated", null, 'product-updates.log');
  93. // }
  94. // public function autoMetaDescription($observer) {
  95. // $product = $observer->getEvent()->getProduct();
  96. // $metaDescription = "Buy ". $product->getName()." for Rs ".number_format($product->getFinalPrice(), 2)." at sitename.com | New Book | Authorised seller for ". $product->getAttributeText('publisher');
  97. // $product->setMetaDescription($metaDescription);
  98. // }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement