Shopp Alternative Google Base Feed

So you’re running a Shopp, you’re going to need a Google Base Feed to stand a chance of attracting traffic.

I got upset at the amount of hacking required to make the Google Base feed (/shop/feed) work correctly.

Google constantly change the requirements for the products feed and it doesn’t seem possible to nicely modify the built in RSS feed for Google.

So here’s how I did mine. It is a little ugly, but it most importantly it works.

  1. Create a new page called Google Base Feed.
  2. Create a new page template in your current theme directory, I called mine template-google-base-feed.php

Here’s the code for that page template

<?php
/*
Template Name: Google Base Feed
*/
?>
<?php
$googleBaseContent = "id    product_url name    description image_url   price   currency    condition   product_type\r\n";
 
shopp('catalog','catalog-products','show=100000000&load=false&order=newest');
if (shopp('category','hasproducts','')):
        while(shopp('category','products')):
            $googleBaseContent .= shopp('product','id','return=true')."\t".
                shopp('product','link','return=true')."\t".
                shopp('product','name','return=true')."\t".
                shopp('product','summary','return=true')."\t".
                shopp('product','coverimage','property=url&return=true')."\t".
                shopp('product','price','return=true')."\tGBP\tNew\tCategory\r\n";
        endwhile;
endif;
?>
 
<?php
trim($googleBaseContent);
$filename = "GoogleBaseFeed_";
$contentLength = strlen($googleBaseContent);
$content = $googleBaseContent;
 
$filename .= date("dMy").".txt";
header('Pragma: private');
header('Cache-control: private, must-revalidate');
header("Content-Disposition: attachment; filename=".$filename);
header("Content-type: text/plain");
header("Content-type: application/octet-stream");
header("Content-length: ".$contentLength);
header("Content-Transfer-Encoding: binary");
 
echo $content;
?>
  1. Assign the new page template to the new page you created.
  2. Add your feed to Google with the path to your new page, probably /google-base-feed/

Job done!

Sub note, my particular feed now needs a “Manufacturer”, so I can easily add this in the code above. Take a note of the last line where I have currently hardcoded Category, Currency and Condition.

PS, I’m not 100% sure on the “show=100000000” parameter, the function is limited to 1000, but I am not sure if it is over writeable.

 

Author: Kieran Barnes

Kieran is a PHP developer with 15 years commercial experience. Specialist in WordPress, CakePHP, CubeCart and all things PHP.

4 thoughts on “Shopp Alternative Google Base Feed”

  1. Hey thanks, this is great! When I’m trying to use this method, nothing is uploading. Google is giving me a message saying “The column delimiter could not be automatically detected from your feed. To select a column delimiter, click edit next to your feed name in your account and select the correct option.”

    I’m a total nube, so I don’t understand most of what’s going on in PhP.. so I went ahead and tried each of the 3 possible delimiter options for my feed (tab, pipe, and tilde), and all of them failed to upload anything.. Google reports in each of those cases that I may have uploaded an empty file.

    Do you know what I’m doing wrong?

    Brad

  2. It is really a nice and useful piece of info. I am glad that you just shared this useful info with us.

    Please stay us informed like this. Thank you for sharing.

Leave a Reply

Your email address will not be published. Required fields are marked *