error_reporting(E_ALL ^ E_NOTICE);
// Read the post from PayPal and add 'cmd'
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc'))
{
$get_magic_quotes_exits = true;
}
foreach ($_POST as $key => $value)
// Handle escape characters, which depends on setting of magic quotes
{
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1){
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
// Post back to PayPal to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
// Process validation from PayPal
// TODO: This sample does not test the HTTP response code. All
// HTTP response codes must be handles or you should use an HTTP
// library, such as cUrl
if (!$fp) { // HTTP ERROR
}
else {
// NO HTTP ERROR
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "ffff";
fwrite($fh, $stringData);
$stringData =$x;
fwrite($fh, $stringData);
fclose($fh);
} else if (strcmp ($res, "INVALID") == 0) {
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "0000";
fwrite($fh, $stringData);
$stringData =$x;
fwrite($fh, $stringData);
fclose($fh);
}
}
}
fclose ($fp);
Sunday, January 2, 2011
Magento Batch tax
Magento Batch Tax:-
1)First Create a tax class for products from sales->tax->product tax class.
2)Now provide tax rate for the products from sales->tax->manage tax zones and rates
3)Now you have to create the tax rule, go to sales->tax->tax rules.Provide information according to your requirement.
4) To assign tax class to all the products in one go just open your magento database and run this sql query UPDATE `catalog_product_entity_int` SET `value` =5 WHERE `attribute_id` =274;
#Here value=5 you can get it from tax class table of your magneto db and attribute id =274 is attribute id of tax class in magento 1.4.1.1 its value is 274 you can check it for you version in your db.
1)First Create a tax class for products from sales->tax->product tax class.
2)Now provide tax rate for the products from sales->tax->manage tax zones and rates
3)Now you have to create the tax rule, go to sales->tax->tax rules.Provide information according to your requirement.
4) To assign tax class to all the products in one go just open your magento database and run this sql query UPDATE `catalog_product_entity_int` SET `value` =5 WHERE `attribute_id` =274;
#Here value=5 you can get it from tax class table of your magneto db and attribute id =274 is attribute id of tax class in magento 1.4.1.1 its value is 274 you can check it for you version in your db.
Magento code to get catalog or product id
$category = Mage::getModel('catalog/category');
$category->load(10);
$collection = $category->getProductCollection();
foreach ($collection as $product) {
$result[] = $product->getId();
$category->load(10);
$collection = $category->getProductCollection();
foreach ($collection as $product) {
$result[] = $product->getId();
Magento Multiple stores
Creating Multiple Stores On Magento
1) First create a root category for second store you wants to add.To add root category follow the below given procedure:-
a) Go to Catalog->Manage categories
b) Add Root category.
c) Provide the desired information and be sure IsActive and IsAnchor is
configured as yes.Now save category.
2)From here Go to system->Manage stores
3)First Create a new website you can name it as you like and also provide its corresponding code.
4)Now for that website you have to create a store.So Now click on create store.
5)Provide information as per your requirements.Set its website property to the newly created website and its root category will be the one which we had created in step 1.
6)Now create a store view for the above created store.Select the store for which you wants to create the view,set its name (eg 'english'), its code and you have to set its status to enabled.
7)After all these stuff you have to create a folder at magento_root for your second store.In that store copy index.php and .htacess from your main magento store.
8)Now you have to edit your second store's index.php file find
“$mageFilename = '../store1/app/Mage.php';”
and replace the path “../store1/app/Mage.php” as you have to locate app/Mage.php of your main magento store.And
at bottom repalce Mage::run() function with Mage::run('storename','website').
9)Now in magento admin panel go to System->Configuration.
10)On the left top side change the scope to your new added store.
11)Now change its web configuration.In unsecure and secure property tab uncheck use website values.
12)Now provide the base url of your second store.
13)Now provide the link url of your second store.If you want to use the same cart for all the stores use link url of your main store else you can also assign it differently.
14)Provide links for skins images,etc as they as refered to images skins of main store.
15)Now save your Configuration.
1) First create a root category for second store you wants to add.To add root category follow the below given procedure:-
a) Go to Catalog->Manage categories
b) Add Root category.
c) Provide the desired information and be sure IsActive and IsAnchor is
configured as yes.Now save category.
2)From here Go to system->Manage stores
3)First Create a new website you can name it as you like and also provide its corresponding code.
4)Now for that website you have to create a store.So Now click on create store.
5)Provide information as per your requirements.Set its website property to the newly created website and its root category will be the one which we had created in step 1.
6)Now create a store view for the above created store.Select the store for which you wants to create the view,set its name (eg 'english'), its code and you have to set its status to enabled.
7)After all these stuff you have to create a folder at magento_root for your second store.In that store copy index.php and .htacess from your main magento store.
8)Now you have to edit your second store's index.php file find
“$mageFilename = '../store1/app/Mage.php';”
and replace the path “../store1/app/Mage.php” as you have to locate app/Mage.php of your main magento store.And
at bottom repalce Mage::run() function with Mage::run('storename','website').
9)Now in magento admin panel go to System->Configuration.
10)On the left top side change the scope to your new added store.
11)Now change its web configuration.In unsecure and secure property tab uncheck use website values.
12)Now provide the base url of your second store.
13)Now provide the link url of your second store.If you want to use the same cart for all the stores use link url of your main store else you can also assign it differently.
14)Provide links for skins images,etc as they as refered to images skins of main store.
15)Now save your Configuration.
Magento Migrate from Os commerce to magento
Migration from OS Commerce to Magento
magento-core/Mage_Oscommerce
Magento comes with a feature for migrating products and catagories from other
CMS like OS-commerce.
Here is the step by step procedure:-
1) Get extention key for Mage-Oscommerce from http://www.magentocommerce.com/extension/specs/114/os-commerce-import
2) Install it Using Magento Connect and it is currently available in beta format so check your magento connect settings.
3) Now copy all your product images from oscommerce catalog to
your magento_root/media/import
4) Now go magento admin panel and select system->Import/export->oscommerce
5) Create a new profile and save it.
6) Now you can Run the import wizard after filling up the appropriate information about the export
7)After the commpletion of the import clear cache usingsystem->cachemanagement
8)Now go to the footer of your magento website select the your oscommerce import to preview it.
** Some time the extension comes with a bug to remove it replace
“app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Run.php”
with Run.php file on given link:-
for version 1.4.x
http://svn.magentocommerce.com/source/branches/1.4-trunk/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Run.php
for version 1.3x
http://svn.magentocommerce.com/source/branches/1.3-trunk/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Run.php
magento-core/Mage_Oscommerce
Magento comes with a feature for migrating products and catagories from other
CMS like OS-commerce.
Here is the step by step procedure:-
1) Get extention key for Mage-Oscommerce from http://www.magentocommerce.com/extension/specs/114/os-commerce-import
2) Install it Using Magento Connect and it is currently available in beta format so check your magento connect settings.
3) Now copy all your product images from oscommerce catalog to
your magento_root/media/import
4) Now go magento admin panel and select system->Import/export->oscommerce
5) Create a new profile and save it.
6) Now you can Run the import wizard after filling up the appropriate information about the export
7)After the commpletion of the import clear cache usingsystem->cachemanagement
8)Now go to the footer of your magento website select the your oscommerce import to preview it.
** Some time the extension comes with a bug to remove it replace
“app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Run.php”
with Run.php file on given link:-
for version 1.4.x
http://svn.magentocommerce.com/source/branches/1.4-trunk/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Run.php
for version 1.3x
http://svn.magentocommerce.com/source/branches/1.3-trunk/app/code/core/Mage/Oscommerce/Block/Adminhtml/Import/Run.php
How read rss data in php
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$xml=("http://api.flickr.com/services/feeds/photos_public.gne");
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);
$i=0;
$x=$xmlDoc->getElementsByTagName('entry');
while($i<8)
{
$entry_con=$x->item($i)->getElementsByTagName('content')
->item(0)->childNodes->item(0)->nodeValue;
preg_match_all('/
]+>/i',$entry_con, $result); /*to read image from xml feed*/
print $result[0][0];
$i++;
}
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$xml=("http://api.flickr.com/services/feeds/photos_public.gne");
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);
$i=0;
$x=$xmlDoc->getElementsByTagName('entry');
while($i<8)
{
$entry_con=$x->item($i)->getElementsByTagName('content')
->item(0)->childNodes->item(0)->nodeValue;
preg_match_all('/
print $result[0][0];
$i++;
}
Subscribe to:
Posts (Atom)