Create a php file in root directory and paste these code.After these code will run then a xml file will be create in root directory.
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
require_once MAGENTO . '/app/Mage.php';
Mage::app();
//$storename='default';
//$file = "products_xml.xml";
//if (file_exists($file)) { unlink ($file); }
?>
<?php
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('entity_id')
->addAttributeToSelect('sku')
->addAttributeToSelect('name')
->addAttributeToSelect('description')
->addAttributeToSelect('short_description')
->addAttributeToSelect('url_key')
->addAttributeToSelect('image')
->addAttributeToSelect('manufacturer')
->addAttributeToSelect('price')
->addAttributeToSelect('product_type')
->addAttributeToSelect('weight')
->addAttributeToSelect('quantity')
->addAttributeToSelect('availability')
->addAttributeToSelect('condition')
->addAttributeToSelect('shipping')
->addAttributeToSelect('tax')
->addAttributeToSelect('is_in_stock')
->addAttributeToFilter('status', array('eq' => '1'))
->addAttributeToFilter('type_id', array('eq' => 'simple'))
->addAttributeToFilter('visibility', 4);
$xml='';
//prep output
$tab = "\t";
$br = "\n";
$xml = '<?xml version="1.0" encoding="UTF-8" ?>'.$br;
$xml .= '<rss version ="2.0" xmlns:g="http://base.google.com/ns/1.0">'.$br;
$xml .= '<channel>'.$br;
$xml .= '<title>https://xpartws.com/</title>'.$br;
$xml .= '<description>Xpartws wholesale corp the personal service you can afford</description>'.$br;
$xml .= '<link>https://xpartws.com/</link>'.$br;
// while loop, this will cycle through the products and echo out all the variables
foreach($products as $_product){
// collect all variables
$total_qty = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
if($total_qty != '0' && $_product->isSaleable()){
$sku = $_product->getSku();
$name = $_product->getName();
$description = trim($_product->getData('short_description'));
$url = 'https://xpartws.com/index.php/'.trim($_product->getData('url_key')).'.html';
$img ='http://xpartws.com/media/catalog/product'.trim($_product->getData('image'));
$condition = $r['productCondition'];
$price = number_format(trim($_product->getPrice()),2);
$weight = trim($_product->getWeight());
/*
require("../includes/config.php"); */
$xml.= '<item>'.$br;
$xml.='<title>'.str_replace('&','&',$_product->getName()).'</title>'.$br;
$xml.='<link>'.$url.'</link>'.$br;
$xml.='<category>Electronics > Communications > Telephony > Mobile Phones > Smartphones</category>'.$br;
$xml.='<description>'.str_replace('&','&',strip_tags($description)).'</description>'.$br;
$xml.='<g:id>'.$sku.'</g:id>'.$br;
$xml.='<g:condition>New</g:condition>'.$br;
$xml.='<g:price>'.$price.'</g:price>'.$br;
$xml.='<g:availability>in stock</g:availability>'.$br;
$xml.='<g:image_link>'.$img.'</g:image_link>'.$br;
/*$xml.= '<g:shipping>shipping</g:shipping>'.$br;
$xml.='<g:gtin>88089927874267</g:gtin>'.$br;*/
$xml.='<g:brand>'.trim($_product->getAttributeText('manufacturer')).'</g:brand>'.$br;
/*$xml.= '<g:isbn>'.$sku.'</g:isbn>'.$br;*/
$xml.= '<g:mpn>'.$sku.'</g:mpn>'.$br;
$xml.= '<g:product_type>'.trim($_product->getTypeId()).'</g:product_type>'.$br;
$xml.= '<g:shipping_weight>'.trim($_product->getWeight()).' lb</g:shipping_weight>'.$br;
$xml.= '<g:google_product_category>Electronics > Communications > Telephony > Mobile Phones > Smartphones</g:google_product_category>'.$br;
$xml.='</item>'.$br;
}
}
/*$xml.= '<item>'.$br;
$xml.='<title>'.$name.'</title>'.$br;
$xml.='<link>'.$url.'</link>'.$br;
$xml.='<description>'.$description.'</description>'.$br;
$xml.='<g:id>'.$sku.'</g:id>'.$br;
$xml.='<g:condition>New</g:condition>'.$br;
$xml.='<g:price>'.$price.'</g:price>'.$br;
$xml.='<g:availability>in stock</g:availability>'.$br;
$xml.='<g:image_link>'.$img.'</g:image_link>'.$br;
$xml.= '<g:shipping>'.$br;
$xml.= '<g:country>US</g:country>'.$br;
$xml.='<g:service>Standard</g:service>'.$br;
$xml.='<g:price>14.95 USD</g:price>'.$br;
$xml.='</g:shipping>'.$br;
$xml.='<g:gtin>8808992787426</g:gtin>'.$br;
$xml.='<g:brand>'.trim($_product->getBrand().'</g:brand>'.$br;
$xml.= '<g:mpn>M2262D-PC</g:mpn>'.$br;
$xml.= '<g:product_type>Consumer Electronics > TVs > Flat Panel TVs</g:product_type>'.$br;
$xml.='</item>'.$br;*/
$xml.= '</channel>'.$br;
$xml.= '</rss>'.$br;
$handle = fopen('google_feeds.xml','w+');
fwrite($handle,$xml);
fclose($handle);
echo "<h2 style=color:green;>Your product data Successfully exported in".' '.'slw-'.date('y-m-d').'-'.time().'.xml'."</h2>";
?>
<strong>Download from here</strong><br />
<a href="https://xpartws.com/google_feeds.xml"><?php echo 'https://xpartws.com/google_feeds.xml'; ?></a><br /><br />
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
require_once MAGENTO . '/app/Mage.php';
Mage::app();
//$storename='default';
//$file = "products_xml.xml";
//if (file_exists($file)) { unlink ($file); }
?>
<?php
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('entity_id')
->addAttributeToSelect('sku')
->addAttributeToSelect('name')
->addAttributeToSelect('description')
->addAttributeToSelect('short_description')
->addAttributeToSelect('url_key')
->addAttributeToSelect('image')
->addAttributeToSelect('manufacturer')
->addAttributeToSelect('price')
->addAttributeToSelect('product_type')
->addAttributeToSelect('weight')
->addAttributeToSelect('quantity')
->addAttributeToSelect('availability')
->addAttributeToSelect('condition')
->addAttributeToSelect('shipping')
->addAttributeToSelect('tax')
->addAttributeToSelect('is_in_stock')
->addAttributeToFilter('status', array('eq' => '1'))
->addAttributeToFilter('type_id', array('eq' => 'simple'))
->addAttributeToFilter('visibility', 4);
$xml='';
//prep output
$tab = "\t";
$br = "\n";
$xml = '<?xml version="1.0" encoding="UTF-8" ?>'.$br;
$xml .= '<rss version ="2.0" xmlns:g="http://base.google.com/ns/1.0">'.$br;
$xml .= '<channel>'.$br;
$xml .= '<title>https://xpartws.com/</title>'.$br;
$xml .= '<description>Xpartws wholesale corp the personal service you can afford</description>'.$br;
$xml .= '<link>https://xpartws.com/</link>'.$br;
// while loop, this will cycle through the products and echo out all the variables
foreach($products as $_product){
// collect all variables
$total_qty = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
if($total_qty != '0' && $_product->isSaleable()){
$sku = $_product->getSku();
$name = $_product->getName();
$description = trim($_product->getData('short_description'));
$url = 'https://xpartws.com/index.php/'.trim($_product->getData('url_key')).'.html';
$img ='http://xpartws.com/media/catalog/product'.trim($_product->getData('image'));
$condition = $r['productCondition'];
$price = number_format(trim($_product->getPrice()),2);
$weight = trim($_product->getWeight());
/*
require("../includes/config.php"); */
$xml.= '<item>'.$br;
$xml.='<title>'.str_replace('&','&',$_product->getName()).'</title>'.$br;
$xml.='<link>'.$url.'</link>'.$br;
$xml.='<category>Electronics > Communications > Telephony > Mobile Phones > Smartphones</category>'.$br;
$xml.='<description>'.str_replace('&','&',strip_tags($description)).'</description>'.$br;
$xml.='<g:id>'.$sku.'</g:id>'.$br;
$xml.='<g:condition>New</g:condition>'.$br;
$xml.='<g:price>'.$price.'</g:price>'.$br;
$xml.='<g:availability>in stock</g:availability>'.$br;
$xml.='<g:image_link>'.$img.'</g:image_link>'.$br;
/*$xml.= '<g:shipping>shipping</g:shipping>'.$br;
$xml.='<g:gtin>88089927874267</g:gtin>'.$br;*/
$xml.='<g:brand>'.trim($_product->getAttributeText('manufacturer')).'</g:brand>'.$br;
/*$xml.= '<g:isbn>'.$sku.'</g:isbn>'.$br;*/
$xml.= '<g:mpn>'.$sku.'</g:mpn>'.$br;
$xml.= '<g:product_type>'.trim($_product->getTypeId()).'</g:product_type>'.$br;
$xml.= '<g:shipping_weight>'.trim($_product->getWeight()).' lb</g:shipping_weight>'.$br;
$xml.= '<g:google_product_category>Electronics > Communications > Telephony > Mobile Phones > Smartphones</g:google_product_category>'.$br;
$xml.='</item>'.$br;
}
}
/*$xml.= '<item>'.$br;
$xml.='<title>'.$name.'</title>'.$br;
$xml.='<link>'.$url.'</link>'.$br;
$xml.='<description>'.$description.'</description>'.$br;
$xml.='<g:id>'.$sku.'</g:id>'.$br;
$xml.='<g:condition>New</g:condition>'.$br;
$xml.='<g:price>'.$price.'</g:price>'.$br;
$xml.='<g:availability>in stock</g:availability>'.$br;
$xml.='<g:image_link>'.$img.'</g:image_link>'.$br;
$xml.= '<g:shipping>'.$br;
$xml.= '<g:country>US</g:country>'.$br;
$xml.='<g:service>Standard</g:service>'.$br;
$xml.='<g:price>14.95 USD</g:price>'.$br;
$xml.='</g:shipping>'.$br;
$xml.='<g:gtin>8808992787426</g:gtin>'.$br;
$xml.='<g:brand>'.trim($_product->getBrand().'</g:brand>'.$br;
$xml.= '<g:mpn>M2262D-PC</g:mpn>'.$br;
$xml.= '<g:product_type>Consumer Electronics > TVs > Flat Panel TVs</g:product_type>'.$br;
$xml.='</item>'.$br;*/
$xml.= '</channel>'.$br;
$xml.= '</rss>'.$br;
$handle = fopen('google_feeds.xml','w+');
fwrite($handle,$xml);
fclose($handle);
echo "<h2 style=color:green;>Your product data Successfully exported in".' '.'slw-'.date('y-m-d').'-'.time().'.xml'."</h2>";
?>
<strong>Download from here</strong><br />
<a href="https://xpartws.com/google_feeds.xml"><?php echo 'https://xpartws.com/google_feeds.xml'; ?></a><br /><br />
No comments:
Post a Comment