I took a peek into the v2.5-RC-2 fm-feed-configs/google-simple.php file and it has not been updated to reflect the newer Google feed requirements.
From what I gather it's missing availability, shipping_weight, and google_product_category. Some missing optional elements include quantity, online_only, color, and additional_image_link.
For shipping weight I added the following into the google-simple.php file...
PHP Code:
'shipping_weight' => array('output' => 'shipping_weight',
'type' => 'FUNCTION',
'options' => array('STRIP_HTML', 'STRIP_CRLF')
),
Then add the following to the functions area...
PHP Code:
function shipping_weight($product) {
//manually add tare weight for now (temp)
return $product['products_weight'] + 1;
}
Note: I did not take the time to pull the tare weight from the database so I just manually entered in the value of '1'.
________________________
For quantity I use...
PHP Code:
'quantity' => array('output' => 'google_quantity',
'type' => 'FUNCTION',
'options' => array('STRIP_HTML', 'HTML_ENTITIES', 'STRIP_CRLF')
),
and...
PHP Code:
function google_quantity($product) {
return $product['products_quantity'];
}
________________________
I also added the use of additional_image_link and MOPICS...
PHP Code:
'additional_image_link' => array('output' => 'additional_images_link',
'type' => 'FUNCTION',
'options' => array('STRIP_HTML', 'STRIP_CRLF')
),
and...
PHP Code:
//functions to support MO_PICS in additional_images_link function
function mopics_file_exists($file_base, $file_types = DYNAMIC_MOPICS_THUMB_IMAGE_TYPES) {
$file_types = str_replace(' ', '', $file_types);
$file_types = preg_split('/[,]/', $file_types);
foreach ($file_types as $file_type) {
if (file_exists($file_base . '.' . $file_type)) {
return $file_type; }
}
return false;
}
function mopics_match_pattern($pattern) {
if (preg_match('/{.*}/U', $pattern, $matches)) {
return $matches[0];
}
return false; }
function mopics_getmethod($pattern) {
return str_replace(array('{', '}'), '', mopics_match_pattern($pattern));
}
function mopics_get_imagebase($image, $pre_append = '') {
return $pre_append . substr($image, ((DYNAMIC_MOPICS_MAINTHUMB_IN_THUMBS_DIR == 'true') ? strlen(DYNAMIC_MOPICS_THUMBS_DIR) : 0), ((DYNAMIC_MOPICS_MAINTHUMB_IN_THUMBS_DIR == 'true') ? (strrpos($image, '.') - strlen(DYNAMIC_MOPICS_THUMBS_DIR)) : strrpos($image, '.')) );
}
function additional_images_link($product) {
$images = '';
///BEGIN MOPICS
// Set the thumbnail basename; replaces "imagebase" in the user's pattern
$image_base = mopics_get_imagebase($product['products_image'], DIR_WS_IMAGES . DYNAMIC_MOPICS_THUMBS_DIR);
// Set the large image's basename; replaces "imagebase" in the user's pattern
$image_base_lg = mopics_get_imagebase($product['products_image'], DIR_WS_IMAGES . DYNAMIC_MOPICS_BIGIMAGES_DIR);
// Get the counting method for the user's pattern (1,2,3; a,b,c; A,B,C; etc)
$i = mopics_getmethod(DYNAMIC_MOPICS_PATTERN);
// Set the search for the str_replace pattern search/replace
$search = array('imagebase', mopics_match_pattern(DYNAMIC_MOPICS_PATTERN));
// Set the initial replace for the str_replace pattern search/replace
$replace = array($image_base, $i);
// Are there any extra thumbnails for this product?
$loopcount = 0;
$first_into_flag = 0;
// Loop until all of this product's thumbnails have been found and displayed
while ($loopcount++ < 100) {
$image_ext = mopics_file_exists(str_replace($search, $replace, DYNAMIC_MOPICS_PATTERN));
if ($image_ext != '') {
// Set large image replacement for the str_replace pattern search/replace
$replace_lg = array($image_base_lg, $i);
// Only link to the popup if a larger image exists
if ($lg_image_ext = mopics_file_exists(str_replace($search, $replace_lg, DYNAMIC_MOPICS_PATTERN))) {
// Set the lar3ge image for this loop
$image_lg = str_replace($search, $replace_lg, DYNAMIC_MOPICS_PATTERN) . '.' . $lg_image_ext;
if ($first_into_flag == 0) $images = $images . tep_href_link($image_lg);
if ($first_into_flag == 1) $images = $images . ',' . tep_href_link($image_lg);
$first_into_flag = 1;
} //if if large image exists
} //end if ext
// Increase current count
$i++;
// Update the replace for the str_replace pattern search/replace for next image in the sequence
$replace = array($image_base, $i);
} //end while
///END MOPICS
return $images;
}
The MOPICS code works and outputs : ...however I have yet to verify if Google has properly read the links.
_________________
When it comes to availability....
PHP Code:
'availability' => array('output' => 'google_availability',
'type' => 'FUNCTION',
'options' => array('STRIP_HTML', 'STRIP_CRLF')
),
and...
PHP Code:
function google_availability($product) {
if ($product['products_quantity'] > 0) return 'in stock';
return 'out of stock';
}
__________________
All my items are online only so I just use...
PHP Code:
'online_only' => array('output' => 'yes',
'type' => 'VALUE'
),
______________________
The tricky part is adding support for google_product_category. If the merchant feed has only products fitting in a certain category then the code is simple, like...
PHP Code:
'google_product_category' => array('output' => 'Home & Garden > Lighting > Night Lights',
'type' => 'VALUE'
),
However, if the store stocks items spread across multiple categories it will be possibly necessary to add the google_product_category information into the database when adding the product to the database (at the new product screen in admin). This mod requires core modification.
Hope this helps... you may look at my feed file if you wish, but it's geared specifically for my store, database, and coding style. Also note, the functions really need to have generic names, ie remove 'google', then have them placed into the proper location of the file 'feedmachine_loadingbay.php' so they can be used by other feed configs such as bing and thefind.
-R
Bookmarks