Skip to main content

Posts

Google Sitemap XML creation in Magento

Recently for a website, I made code for Google Sitemap. This script creates product xml which we need to list our products in Google. To create this follow below process: Create a php file and put it on root. Lets name the file Googlexml.php  This file will create an xml file whenever we hit the file.  We also needs to make a destination directory for output xml file inside media folder. Let's say the folder name is /GMC. Output file would be automation.xml. That's it, let's start the coding part. Please copy and paste below script in Googlexml.php file. <?php if($_SERVER["DOCUMENT_ROOT"]) {     $documentRoot = $_SERVER["DOCUMENT_ROOT"]; } else {     $pathArray = explode('Googlexml.php', $_SERVER["SCRIPT_NAME"]);     $documentRoot = $pathArray[0]; } require_once $documentRoot.'/ROOT_FOLDER/app/Mage.php'; Mage::app(); $products = Mage::getModel('catalog/product')->getCollection()      
Recent posts

Programatically Delete Products by Sku ( Using CSV )

Hi All, Recently while working on a project. I need to delete products from Magento and I only have a CSV having all the product's SKU. For that I have written a script which reads SKU from CSV file and deleting products. Below is the code which you can use: <?php //Path to Magento require_once('app/Mage.php'); umask(0); Mage::app(); ini_set('display_errors', 1); // Register a secure admin environment Mage::register('isSecureArea', 1); $file = "remove_product.csv"; // CSV File name with SKU's $fileData=fopen($file,'r'); if (($handle = fopen("remove_product.csv", "r")) !== FALSE) {   while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {     $num = count($data);     $row++;     for ($c=0; $c < $num; $c++) {         echo $data[$c] . "<br />\n";         $sku = $data[$c];         $product = Mage::getModel('catalog/product')->loadByAttribut

Magento Multiple Store Setup

Many times we need to create multiple stores in magento website. In magento we create different stores to make it more local. We can access different stores using below ways: 1) Domain (e.g. www.store1.com and www.store2.com) 2) Subdomain (e.g. store1.mystore.com and store2.mystore.com) 3) Folder (e.g. mystore.com/store1/ and mystore.com/store2/) Its all upto to you which way you prefer. For all these we need to follow below steps: Step 1: Add new Magento store: It might be possible that both store have different  catalogue so to manage this. We need to make two different Base Categories. To create a new base category follow below steps: Log in to your Magento admin panel. Go to Catalog -> Manage Categories . If you want both your websites to share same “ Default Category ”, select it by clicking on it on the left. Or click Add Root Category to create a new root category different from the existing one. Once the category is selected, under the General

Memcache with Magento : Magento speed like Rocket

Hi Fellas, I am sharing this article showing how we can use the power of memcache alnog with magento. One of major magento drawback would be its speed, although we can several ways to speed up. Memcache is good option as its new and fast. Before starting lets know a bit about what is memcache. Memcache is used to fast access database, api and etc. For this it uses some space on server. For more information please visit: http://www.memcached.org/ You can use below method to apply memcache for Magento v1.9 and older. Below are the steps for starting memcache on your magento store: 1) Go to app/etc/ and find local.xml file. 2) Find the </global> tag and paste below code before the tag. <cache> <cache>     <backend>memcached</backend>     <slow_backend>database</slow_backend>     <fast_backend>Memcached</fast_backend>     <fast_backend_options>         <servers>             <server>             

Magento Speed Optimization

E-commerce website needs to so fast that customer need not have to wait much. In current scenario time is very important aspect for an e-commerce store. Below I will let you know how you speed up your online store and increase your website performance. 1) Minify JS and CSS: Website have so many js and css. It takes alot of time to load the home page. It will give a bad impression if website home page took long to open. We need to minify JS and CSS of magento store. For merging CSS files: 1) Login into magento admin panel. 2) System -> Configuration -> Developer -> Merge CSS files For merging JS files: 1) Login into magento admin panel 2) System -> Configuration -> Developer -> JavaScript setting -> Merge JavaScript files 2) Gzip Compression: Gzip compresses web pages and stylesheets at the server level before sending them over to the browser. <IfModule mod_deflate.c> # Compress HTML, CSS, JavaScript, Text, XML and fonts AddOutputFilterBy

Magento - Get product by sku

Hi Everybody, I was working with magento products and found that how we can find product object using sku and I have found below solution. // Here $sku is our sku variable for product. $sku = 'A1001' ; //loadByAttribute function is helpful for getting product data $product = Mage:: getModel ( 'catalog/product' ) -> loadByAttribute ( 'sku' , $sku ) ;

Angular JS Table Filter and Sorting

Hi All, I am new to angular js and doing some random stuff. I am sharing the code here. Hope this will help you some where. <style> table, td  {   border: 1px solid grey;   border-collapse: collapse;   padding: 5px; } .sortorder:after {   content: '\25b2'; } .sortorder.reverse:after {   content: '\25bc'; } </style> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <body> <div ng-app="myApp" ng-controller="customersCtrl"> <table>     <tr>         <td ng-click="order('Name')">           Customer Name           <span class="sortorder" ng-show="predicate === 'Name'" ng-class="{reverse:reverse}"></span>         </td>         <td ng-click="order('City')">           City           <span class="sortorder"