From Gallery Codex
Zencart Integration Module
Integrates Gallery2 and Zencart 1.3.8a
Author: Dayo Akanji
Current version: 3.2.4
Gallery Version: Gallery 2.3.0
Download the module files here.
Download a patched version of Zencart 1.3.8a here.
This patched version has the module files required on the zencart side preintegrated as well as several bugfixes including PHP 5.3.x compatibility and all announced security patches up to 14 Jan 2010.
If you will rather use the official Zencart 1.3.8a Release, you can get it here.
Note that you will need an additional step in installation and more importantly, you will have to add the various bugfixes and security patches yourself.
The official patch that comes up in the admin section after installation is NOT comprehensive. Further actions are needed to be fully secure and bugfree.
Visit the Zencart Forums to for a full list of security patches and bugfixes to apply including the PHP 5.3.x compatibility patch.
Visit the Support Site for enquiries and support requests.
Requirements
- Gallery 2.3.x
- Zencart 1.3.8a
- Both must use the same database
Description
The Gallery2/Zencart integration module allows users to organize their photos and other multimedia files in Gallery2, a web-based photo album organizer, while simultaneously offering them for sale through Zencart, a powerful open source e-commerce application. This module was originally developed for Zencart 1.2.7 as part of Google's 2005 Summer of Code by Michael Rodriguez-Torrent. Additional work by Chuck Redman to update it for Zencart 1.3.7. Updates for Zencart 1.3.7 finalised by Dayo Akanji. Updated for Zencart 1.3.8a by Dayo Akanji.
Features
- Easy, painless, installation.
- Return to previous Gallery2 page from any Zencart page
- Items and albums from Gallery are automatically synchronized as products and categories in Zencart.
- Set default options and pricing of Gallery products and use Zencart to customise individual items.
- Comes with Gallery2 templates (Based on PGTheme Color Packs) that will also match most Gallery2 Themes or serve as a basis for customisation.
Installation
Notes
- Click here to download the module files.
- Uninstall any versions of the module predating Version 3.0.0 in Gallery2 Admin first if you have one installed.
- You will lose your Zencart configuration after you do this!!
- It is helpful to have the Rewrite Module active before installing this module.
- Only actual data items (photos, movies etc) can be added to Zencart through this module. Albums cannot be added.
First, Install Zencart
- Download a patched version of Zencart 1.3.8a here.
- Unpack the file into your Gallery2 folder and rename it as you wish to call your online store (e.g. mynewstore). This will allow you to have a directory structure such as wwww.yoursite.com/gallery/mynewstore.
- Launch your browser and navigate to the Zencart folder and follow the instructions to install it. Use the same database name as Gallery2, but use different a table prefix for the Zencart database.
Then, configure Zencart if not using supplied patched Zencart fileset
- Upload the contents of the "zencart" folder from this module package to the mynewstore folder.
- Log in to Zencart as Admin at "yoursite.com/gallery/mynewstore/admin".
- Select "Tools" >> "Template Selection" and choose one of the Gallery2 Integration Templates provided.
- Select "Catalog >> Categories/Product >> New Category" and create a new category called "ZCG2".
Then, In Gallery2
- Upload the module files in "gallery2" to your Gallery2 modules directory.
- In your Gallery2 Site Administration, click on "Plugins," find "Zencart" under the "Commerce" heading, and click "Install"
- After Installation, click "Configure"
- Enter the full server path to your Zencart installation. E.G. "/home/you/public_html/Gallery2/mynewstore/".
(NOTE: You must enter the full server path and not a relative path. Some features will fail if a relative path is used)
- Click "Save"
- Select "ZCG2" from the drop down menu after the page refreashes.
- Click "Save"
- Activate the module.
- Refresh the page and click on the Zencart link under "Admin Options" to edit product details
- Edit permissions for the individual items as you wish. The module will have assigned permissions to non album items on activation.
(NOTE: To prevent items being bought, you will have to disable them in Zencart as the module adds all data items in your gallery to Zencart. You can also add password protection as described under "Access Control" below)
Finally, tweak the site settings in Zencart
- Replace "/mynewstore/includes/templates/pgxxx/images/logo.gif" with one for your site.
- Edit the line "Designed by Dayo Akanji" with a suitable tagline for your site
- You can take a copy of the template folder (/mynewstore/includes/templates/pgxxx) and modify stylesheet.css to taste. If you do this, also create copies of "/mynewstore/includes/languages/pgxxx" and "/mynewstore/includes/languages/english/pgxxx" with the same name and case structure as the copy. Also edit "/mynewstore/includes/templates/pgxxx/template_info.php".
(NOTE: Creating a custom template in this manner may result in updates to the module not being applied to your insallation. Similarly, if you edit in situ, updates may overwrite your changes)
- Read and apply the Zencart Tutorial on securing your Zencart installation.
If you change the name of your Zencart admin folder as advised in the tutorial, you will need to make some changes to the g2 module code.
To do this, go to "/gallery/modules/zencart" and open "ZenCartAbstraction.class". Change every instance of $this->_path . 'admin/xyz/xyz' to $this->_path . 'YourNewFolderName/xyz/xyz'.
General Notes
- To add Gallery items to Zencart, simply add items to your Gallery.
- To change default pricing and options, click on "Zencart" in your Site Administration menu.
- The Product Category specified as the 'root' category for Gallery2 images should NOT be the top 'Main' category in the Zencart store.
- All Gallery2 items are automatically given an item type of "Product-Gallery". If this is changed to a different category e.g. Product-Free or Product-Free Shipping, the Gallery connection will be broken.
- The Gallery2 Bridge will coexist happily with the Zencart Image Handler and Lightbox Add On, but does NOT interact with them. i.e. they work with products added in the normal way in Zencart while the Gallery2 addon works with the images added in Gallery2.
Access Control
Password Protect Albums
- To password protect an album...
- Open /mynewstore/includes/templates/pgxxx/common/tpl_check_albums.php.
- Edit "#_01" etc in 'case "#_01"' etc to reflect the cPath name of albums to be restricted.
- The cPath value can be found in the address bar after navigating to the album within Zencart eg "...&cPath=1_23".
- Edit each instance of $myusername, $mypassword, $areaname & $access_details as required.
Password Protect Individual Items
- To password protect an item...
- Open /mynewstore/includes/templates/pgxxx/common/tpl_check_items.php.
- Edit "#_01" etc in 'case "#_01"' etc to reflect the products_id name of items to be restricted.
- The products_id value can be found in the address bar iafter navigating to the item within Zencart eg "...&products_id=123".
- Edit each instance of $myusername, $mypassword, $areaname & $access_details as required.
Troubleshooting
Known issues:
- I get a host of errors after trying to add images to my gallery with the module activated.
- Solution: If this is happening with an empty gallery and those are the first images being added, you are probably using a version before Version 3.1.0. If this is the case, upgrade to current version and try again. If the problem persists, deactivate or uninstall the module in Site Admin, add a couple of images to the gallery and then reactivate the module.
- Thumbnails for Gallery products are not displayed in Zencart in some instances.
- Solution: This may be caused by a limitation in Zencart which restricts the length of the thumbnail URL. As a result, if you are not using URL rewrite or if your Zencart and Gallery2 directories are particularly far away, the URLs may be too long and thumbnails will not be displayed. To correct this, try activating URL rewrite. Alternatively, or if URL rewrite does not solve the problem, do the following:
- Run this query on your Zencart database (where "PREFIX_" is your Zencart table prefix, generally "zen_"): ALTER TABLE `PREFIX_products` CHANGE `products_image` `products_image` VARCHAR (255)
- Check the "Enable long thumbnail URLs" box in the Zencart module options in Gallery2.
- Deactivate and reactivate the module to update the thumbnails in Zencart.
- The above ALTER may also be needed for the categories_image column of categories table.
- Category thumbnails in Zencart are squashed or not the right size.
- Solution: Set your album thumbnails and your Zencart subcategory images to the same dimensions.
- Items are added with a set quantity (9999) -- I would like to offer an unlimited quantity (or a more limited quantity).
- Solution: Go to Gallery->Modules->Classes->GalleryZenCart.class and edit this line: "$data = array('products_quantity' => '9999.0',". Any new items you add should be imported into Zencart with the new quantity you set. To change existing items, run this query on your Zencart database (where "PREFIX_" is your Zencart table prefix, generally "zen_" & MY_QTY is the quantity you wish to assign as default): UPDATE `PREFIX_products` SET products_quantity = 'MY_QTY' where products_id = '*'.
- The order list only shows me the item title -- some of my items have the same title and I'd like to know where to find the right one.
- Solution: Please give your items unique titles. Every store has to have unique id numbers for items and since you are running a store, you have to do the same or things will descend into chaos. Note that a unque ID is appended to the item in Zencart though.
- I tried to change my integration category from Top to a subcategory and it moved all my categories, even non-Gallery ones.
- Solution: Change back to Top, deactivate, uninstall, and reinstall the module. Configure with your new category and reactivate the module.
- I deactivated the module and deleted the integration category in Zencart and now I can't reactivate the module to change it.
- Solution: Uninstall the module, reinstall, and configure with your new category choice. Delete the integration category only after you have selected a new one or have uninstalled the module.
- I want to set pricing per-item / offer a sale on a item / remove an option from an item / etc.
- Solution: Go to your Zencart administration and edit the item as you would any other product. All custom pricing, options, and values you apply will remain until you uninstall the module. Please note that any custom quantities will be reset if the module is deactivated and reactivated.
- I have general or synchronization problems
- Solution: Deactivating and reactivating the module in Gallery will resynchronize your entire Gallery with their Zencart Items and should cure any synchronization problems that have occurred for any reason (please report bugs!).
- Things are getting really ugly
- unistall the module in Gallery2
- delete the Zencart category that held the Gallery2 products
- using your favourite database management software such as phpMyAdmin, delete all entries beginning with "zc_" (or whatever your Zencart Table Prefix is) in your Gallery2 ExternalIdMap table.
- Finally, reinstall the module in Gallery2.
Uninstall
- In your Gallery2 Site Administration, click on "Modules," find "Zencart" under the "Commerce" heading, and click "deactivate."
- Click "uninstall" next to "Zencart" in the module list.
- Optionally, delete the module files that you uploaded when installing.