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