Skip to main content

Posts

Showing posts from April, 2017

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