[Module] Froogle Static export

Modules, Add-ons and custom code that's more than just a quick hack or Mod.
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

[Module] Froogle Static export

Post by Martin »

Title: "Froogle Static" export
Author: Martin Smallridge (WebSnail)
License: Opensource
Cost: Free
Version: 1.0.5 (revision 87)
Compatible: 4.0.x / 5.0.0 - 5.0.x

New Version (1.1.0 -> )
Title: "Froogle Static" export
Author: Martin Smallridge (WebSnail)
Cost: Paid
Purchasing: SnailSolutions
Version: 1.1.0 (revision 242)
Compatible: 6.x

This little module was cooked up by simply stripping a lot of the "are you allowed" code and interface info on progress from the admin export function for froogle.

What does it do
This module simply exports your entire product list into a Froogle/GoogleBase friendly format using a static filename (instead of the dynamic one created in the admin version) so you can tell Google to grab this regularly.

If you set a CRON job (ie: scheduled task) to run the froogle.php file your file will be automatically re-generated according to the schedule you set.

Security Issues?
It does mean that your entire product catalogue can be easily downloaded by a competitor, etc...

This is by no means perfect as someone with a lot of time could potentially use a brute force method to find the file but you can edit the class.froogle.php file and change the $exportFile variable to something a bit more obscure
eg: $exportFile = "DU32_ccvEds238DF.xml";
NB: Remember to included the .xml file extension or it will not be interpreted properly by google.

So, long as you give Google the correct full path and filename you should be fine.

How to install
Copy the two files into your existing Interspire installation
  • \froogle.php
  • \includes\classes\class.froogle.php

What to pass on to Froogle/GoogleBase
The URL for your product list will be
http://yoursite.url/[store_directory?]/cache/froogle-export.xml

If you've changed the value for $exportFile you will need to put that value in place of "froogle-export.xml"
eg: http://yoursite.url/[store_directory?]/cache/DU32_ccvEds238DF.xml


Setup CRON
Ref: http://www.modwest.com/help/kb5-125.html
If your PHP scripts do not have executable permissions, 644 or -rw-r--r-- for example, then as part of the command portion of the cron line, you must specify the php interpreter and pass it the filename of the PHP script (including full path to the script from your home directory) that you want executed, like so:

Code: Select all

28 14 * * * /usr/local/bin/php -q /home/account/public_html/store/froogle.php
The first cron line above will run myscript.phtml located in your home directory every day at 2:28PM.
You need to set the path to the file properly so if you have a hosting account of "foo" with your store in the main/root directory you'd use this path:
/home/foo/public_html/froogle.php


Changelog
  • 1.0.5 : Revision 87:
    • GBP, EUR and USD specific lists now created
    • exportFile remains as before for default currency
    • skips any currencies that don't exist
    • Prepends other currency files with the currency code eg: USD_froogle-export.xml
    • No other changes necessary
  • 1.0.4 : Revision 34:
    • Update changes from ISC 4.0.9 that provide the "condition" field
    • Default "condition" field to "new" if the condition field in database is not present or set (ie: backwards compatibility)
    • Add $show_quantity option to show inventory quantities (set to true by default)
    • Hide Quantity attribute for any items with a zero stock level even if $show_quantity is set to true
  • 1.0.3 : Revision 31:
    • Duplicate product list now optional using $ignore_duplicates variable in class.froogle.php
    • Summary attribute/tag deprecated in favour of Description (as per documentation rather than out of date example on GoogleBase)
    • Weight attribute/tag added for any products with weights set
    • Tidied up formatting to produce a clean XML output
    • More informative comments to help with editing, etc..
  • 1.0.2 : Revision 29:
    • Code now strips out duplicate product listings so that products only appear once instead of multiple times (if in multiple categories)
    • Added revision, author and date information to make it easier to track changes
  • 1.0.1 : Revision X:
    • Fix invalid path issue when calling froogle from the CRON
  • 1.0.0 : Revision X:
    • Initial release
Attachments
Froogle static-1.0.5.zip
1.0.5
(15.22 KiB) Downloaded 833 times
Froogle static 1.0.4.zip
1.0.4
(4.37 KiB) Downloaded 746 times
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: [Module] Froogle export (alt)

Post by Martin »

Just to note that setting up CRON is a bit of a pain for the inexperienced so I'd ask your host to help if you can...

Other useful nuggets can be found in this article and in the comments in particular:
http://www.developertutorials.com/blog/ ... n-php-172/
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: [Module] Froogle Static export

Post by Martin »

EDIT: Ok... fixed the issue that would have borked CRON.

It required realpath() to be able to figure out the actual path for CRON so if your host has disabled realpath() for security reasons you can work around this by editing class.froogle.php

Find:

Code: Select all

$this->localpath = realpath(dirname(__FILE__)."/../../");
Replace With edited version of this:

Code: Select all

$this->localpath = "/path/to/your/store";
NB: No trailing slashes!
Tony Barnes
Posts: 744
Joined: Thu Jun 18, 2009 8:59 am

Re: [Module] Froogle Static export

Post by Tony Barnes »

Excellent mod - hook yourself up to Froogle and forget about it! The way it should of been from the start ;) :mrgreen:
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: [Module] Froogle Static export

Post by Martin »

Forgot to mention that this mod includes the workaround for the new Condition field requirement in froogle...

I'll update if/when it's dealt with in the main Froogle admin code.
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: [Module] Froogle Static export

Post by Martin »

The original Froogle code by Interspire doesn't differentiate between products that have already been added to the list or not. The result is you end up with a bloated product list with duplicates thrown in that aren't required...

This has been fixed in version 1.0.2 (revision 29) but I've included this code here so you can modify your existing froogle code in the admin system to remove duplicates as well.

File: class.froogle.php

Find:

Code: Select all

            while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
Replace with:

Code: Select all

            $exported = array();    // Track exported products to avoid duplication
            
            while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                
                // If we've already exported this product we don't want to send it again!
                if(@$exported[$row['productid']]) {
                    continue;
                }
                $exported[$row['productid']] = true;

Version 1.0.3 released.
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: [Module] Froogle Static export

Post by Martin »

That'll teach me to shoot off my mouth..

I missed that the froogle code original was using <g:department></g:department> as the pseudonym for "category" so it seems there was a purpose for that particular function after all.

I'll release 1.0.4 when I've had a chance to see if a couple of other changes I made to the code tags has helped with another issue.

This will provide the option to ignore duplicates or not

Code: Select all

			// EDIT ME Set to true if you want only one product regardless of number of categories the product is in
			$this->ignore_duplicates = false;
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: [Module] Froogle Static export

Post by Martin »

Having finally gotten Google Base to accept one of my updates I've made a couple of minor changes using the successful code and released version 1.0.3 (revision 31).

The changelog says it all but the primary change of interest is the removal of the summary tags/attributes and replacement with description. I couldn't be 100% sure but it seems that Googlebase may have opted to drop summary.. either way it seems to have accepted the change.

I've also added in the weight attribute/tag for any items that have weights applied in the ISC entry so that'll keep the warnings off your back too...

As always, read the readme.txt file and this thread for more info...



Oh and if you're actually using this.. remember to say thank-you. Manners cost nothing but are worth everything... 8-)
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: [Module] Froogle Static export

Post by Martin »

Right... 1.0.4 has been released with the updates shown below.. :)

Changelog
  • 1.0.4 : Revision 34:
    • Update changes from ISC 4.0.9 that provide the "condition" field
    • Default "condition" field to "new" if the condition field in database is not present or set (ie: backwards compatibility)
    • Add $show_quantity option to show inventory quantities (set to true by default)
    • Hide Quantity attribute for any items with a zero stock level even if $show_quantity is set to true

Also worth noting that Googlebase might be working a bit better now too...
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: [Module] Froogle Static export

Post by Martin »

Well, this little nugget has just made my day...
http://www.interspire.com/forum/showpos ... stcount=67

Not sure whether to laugh or cry...


Anyway, it seems that all my work has pretty much been nullified by a development change in the ISC code itself... It's not into 5.0.4 but it has arrived in 4.0.9.

Some of the features I've implimented aren't included in the ISC release so it's still valid but there is definitely the advantage of not having to mess about with CRON on ISC's offering. I've let Chris know about my changes so hopefully something might get incorporated in to bring ISC up to speed...

Anyhoo... back to my Parcelforce code... at least that isn't likely to be taken over :)
Post Reply