Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Tuesday, May 21, 2013

How to post data using curl / Zend_Http_Client

using curl
$data = array("name" => "Hagrid", "age" => "36");     
$jsonData = json_encode($data);
$handle = curl_init();
$url = 'http://magento.com/customer/account/login';
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $jsonData);
$response = curl_exec($handle);
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);
using Zend_Http_Client
// new HTTP request to some HTTP address
$client = new Zend_Http_Client($url);
// set some parameters
$client->setParameterPost('data', $jsonData);
// POST request
$client->request(Zend_Http_Client::POST);

Wednesday, October 5, 2011

Export Magento categories with ID using php script

Copy the code below into a new file "categorywithid.php" and place this file in your root folder
define('MAGENTO', realpath(dirname(__FILE__)));
require_once MAGENTO . '/app/Mage.php';
Mage::app();

$category = Mage::getModel ( 'catalog/category' );
$tree = $category->getTreeModel ();
$tree->load ();

$ids = $tree->getCollection ()->getAllIds ();

if ($ids) {
 $file = "var/export/catwithid.csv";
 file_put_contents($file,"catId, catName\n");
 foreach ( $ids as $id ) {
   $string = $id . ', ' .$category->load($id)->getName() . "\n";
  file_put_contents($file,$string,FILE_APPEND);
 }
}
Hit Your browser like www.YourDomain.com/categorywithid.php Thats it. You are done. Get the csv file under "var/export/catwithid.csv".

Tuesday, September 20, 2011

Maximum execution time of 30 seconds exceeded

To fix it, open your php.ini and replace the value for 'max_execution_time' and 'max_input_time' as per below.
max_execution_time = 3600
max_input_time = 3600