Sunday, April 17, 2011

Zend Frame work

Zend Frame work is a php based frame work, we use frameworks to make our work easy and to add security and stability to our code zend framework is a very strong framework with lots of features which are included in its library and has a strong security features that's why it is used for eCommerce cms like Magento.

Zend is based om MVC structure like we have separate files for user view, controllers and business logic.

Sunday, February 6, 2011

magento product api

$proxy = new SoapClient('http://nonanecorp.com/diamond/diamond/index.php/api/soap/?wsdl');
$sessionId = $proxy->login('kapil', 'kapil123');


$filters = array(
'sku' => array('like'=>'diamond%')
);

$products = $proxy->call($sessionId, 'product.list', array($filters));

foreach ($products as $value) {
$record[]=$proxy->call($sessionId, 'product.info', $value[sku]);
var_dump($record);

}

magento session

Mage::getSingleton('customer/session')
function to get session data of the magento

Sunday, January 2, 2011

pay pal ipn example

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);

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.

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();

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.