Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Macsanta_OnProductSave_Model_Observer {
- private function teest(){
- echo "string";
- }
- public function catalogProductSaveAfter(Varien_Event_Observer $observer)
- {
- $this->teest();
- $url = 'https://www.promoplace.com/ws/ws.dll/SITK';
- // $data = array('Request' => 'ProductDataDownload', 'APIVer' => 200, 'Auth' => array('AcctID' => '7496', 'Token' => '70ef35e852550f5f91b56cb3c2db8211' ), 'SAGENum' => 50681, 'Products' => array('NotPictured' => 0));
- //
- // $data = [
- // "Request" => "ProductDataDownload",
- // "APIVer" => "200",
- // "Auth" => [
- // "AcctID" => 7496,
- // "Token" => "70ef35e852550f5f91b56cb3c2db8211"
- // ],
- // "SAGENum" => 50681,
- // "Products" => [
- // "ProductID" => 9180
- // ]
- // ];
- $data = [
- "Request" => "ProductDataDownload",
- "APIVer" => "200",
- "Auth" => [
- "AcctID" => 7496,
- "Token" => "70ef35e852550f5f91b56cb3c2db8211"
- ],
- "SAGENum" => 50681
- ];
- // use key 'http' even if you send the request to https://...
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/json\r\n",
- 'method' => 'POST',
- 'content' => json_encode($data)
- )
- );
- // var_dump($options);
- $context = stream_context_create($options);
- $result = file_get_contents($url, true, $context);
- if ($result === FALSE) { /* Handle error */ }
- var_dump(json_decode($result));
- // Your ID and token
- // $authToken = '70ef35e852550f5f91b56cb3c2db8211';
- //
- // // The data to send to the API
- // $postData = json_encode($data);
- //
- // // Setup cURL
- // $ch = curl_init('https://www.promoplace.com/ws/ws.dll/SITK');
- // curl_setopt_array($ch, array(
- // CURLOPT_POST => TRUE,
- // CURLOPT_RETURNTRANSFER => TRUE,
- // CURLOPT_HTTPHEADER => array(
- // 'Authorization: '.$authToken,
- // 'Content-Type: application/json'
- // ),
- // CURLOPT_POSTFIELDS => json_encode($postData)
- // ));
- //
- // // Send the request
- // $response = curl_exec($ch);
- //
- // // Check for errors
- // if($response === FALSE){
- // die(curl_error($ch));
- // }
- //
- // // Decode the response
- // $responseData = json_decode($response, TRUE);
- //
- // // Print the date from the response
- // var_dump($responseData);
- // echo "hello";
- exit();
- return $this;
- }
- // public function logUpdate(Varien_Event_Observer $observer)
- // {
- // $product = $observer->getEvent()->getProduct();
- // $name = $product->getName();
- // $sku = $product->getSku();
- //
- // Mage::log("{$name} ({$sku}) updated", null, 'product-updates.log');
- // }
- // public function autoMetaDescription($observer) {
- // $product = $observer->getEvent()->getProduct();
- // $metaDescription = "Buy ". $product->getName()." for Rs ".number_format($product->getFinalPrice(), 2)." at sitename.com | New Book | Authorised seller for ". $product->getAttributeText('publisher');
- // $product->setMetaDescription($metaDescription);
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement