Google Merchant How To Setup A Live XML Data Feed With MySql and PHP
来源:互联网 发布:mysql front下载 编辑:程序博客网 时间:2024/05/21 14:03
Setting up a live data feed for Google Merchant (Google Shopping) can be tricky if you don’t know how to set it up. I could not find one topic that covered from a to z how to set up a Google Merchant Feed. This article will cover how to create a database, retrieve information using PHP and automatically generate a Google Merchant XML feed.
Requirements :
- basic knowledge of PHP
- basic knowledge of MySQL
First go and get yourself a Google Shopping Account and fill out all your details for registration (It’s a very simple process). You can also connect your Google Adwords account to your Google Shopping account.
Now that you have already created an account lets delve on in-depth information on how to set-up a live data feed. If you already have a database with products please ignore the next part and go to required fields and explanation.
Step One : Setting up a MySQL database
Below I have created a simple MySQL code for you to use the bare minimum Google Shopping would need, now this means it’s not covering products such as clothing, if you need more details about it, please check the xml example here.
- Login to your MySQL CMS system, most likely phpMyAdmin
- Go to the tab SQL
- Copy and Paste the below code into the text area and click on Go
CREATE TABLE products (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,productID VARCHAR(32),brand VARCHAR(32),price VARCHAR(12),title VARCHAR(225),description TEXT,pageLink TEXT,stock VARCHAR(32),gmCategory TEXT,productCondition VARCHAR(50),image VARCHAR(225),shippingCountry VARCHAR(3),shippingService VARCHAR(1),shippingPrice VARCHAR(10),GTIN VARCHAR(15),MPN VARCHAR(50),productType TEXT);
Required fields and explanation:
If you need an explanation to what all these fields are, simply look at the support files here. Within the xml file as an example you will see what the minimum requirements are for publishing products into Google Shop.
Insert some data as a test example
Step Two : Generating our XML file
Below is an example I have used for generating an example file. If you have imported the table from step one, than the php code below will generate the correct information. If not than most likely you want to change the fetched arrays within the script.
php// mysql connection$conn=mysqli_connect("localhost","database","password","database_name");// Check connectionif (mysqli_connect_errno($conn)){echo "Failed to connect to MySQL: " . mysqli_connect_error();}// Collect data in query$q = mysqli_query($conn,"SELECT * FROM products ");// Set the xml headerheader("Content-type: text/xml");// Echo out all the detailsecho 'smileywar.comhttp://www.smileywar.comGoogle Shopping Feed';// while loop this will cycle through the products and echo out all the variableswhile($r = mysqli_fetch_array($q)){// collect all variables$title =$r['title'];$link =$r['pageLink'];$description =$r['description'];$productID =$r['productID'];$condition =$r['condition'];$price =$r['price'];$stock =$r['stock'];$image ='http://www.smileywar.com/_images/GoogleMerchant/'.$productID.'.jpg';$category ='Vehicles & Parts > Vehicle Parts & Accessories > Motor Vehicle Exterior';$gtin =$r['GTIN'];$mpn =$r['MPN'];// output all variables into the correct google tagsecho "$title$link$description<g:google_product_category>$category$productID$condition$price GBP$availability<g:image_link>$imageUKStandard5.95 GBP$gtinThule$mpn<g:product_type>$category";}echo "";?>
Save this file as index.php and upload it to a folder such as http://www.mysite.com/GoogleShoppingFeed remember to htaccess this folder so that your data can’t be downloaded by others. Browse to your folder, login and now you can see your xml data.
In Google Shopping Centre navigate to data feed, and enter in a name for example ShoppingFeed.xml and click on continue. In the second column under upload, click on Monthly/Weekly upload, here you enter in your URL, username and password for which you have added to your htaccess file, select the recurrence of your data download, for example every week on a Monday.
And that’s it. All done, now you have set up a live data feed as to which you only have to update in your server’s database and not multiple xml or text files.
Once you have finished your setup, you might be interested in how to optimize your feed in generating the highest ranks in Google Shopping and how to setup a custom Google Merchant product.
- Google Merchant How To Setup A Live XML Data Feed With MySql and PHP
- How to setup multiple data sources with Spring and JPA
- How to setup multiple data sources with Spring and JPA
- How to setup a GIT server with gitosis and gitweb
- How To Setup a Rails 4 App With Apache and Passenger on CentOS 6
- How to Create a High Availability Setup with Pacemaker, Corosync and Floating IPs on CentOS 7
- How to Do Everything with PHP and MySQL
- How to Integrate angular 2 with php and mysql db
- How to Setup Apache With FastCGI And Ruby Bindings
- how to setup mysql
- How to Setup a Linux Firewall with PPPoE/NAT/iptables
- How to setup a Mac with Python dev tools
- How to Make a VR Game With Unity and Google Cardboard
- How to Train a ChatBot with the TensorFlow and Google Cloud ML
- How To Setup a CA
- How to Setup A Database
- How to install Nginx, PHP, PHP-FPM and MySQL under Windows with Cygwin
- ios php mysql How To Make an iPhone App with MySQL and WordPress
- JDom中removeContent无法删除子元素问题
- ubuntu 重启命令,ubuntu 重启网卡方法
- MyEclipse快捷键大全
- 一叶知秋
- dm9000
- Google Merchant How To Setup A Live XML Data Feed With MySql and PHP
- Android ProGuard使用要点!
- Hacker delight
- sublime 我常用快捷键
- 关于Eclipse中安装Maven时产生的错误
- 多台 FreeSWITCH 服务器级联
- Android编程中的常见问题及解决办法
- 网络相关文章--学习
- 相册用缩略图生成类(C#,ASP.NET),自适应图像比例。