Jump to content

[Resolved] Need help with Bing Feed


Dirty Butter

Recommended Posts

I have created a Bing Feed plugin based on the Google Base one. Bing has emailed today admitting used items to their Product Ads. That means I need to not only show the condition as it is done on Google, but I also need to append Used to the product titles.

Is there a way to add code to concatenate the string "with a space-another spaceUsed" to the end of the name array?

if($_GET['format'] == 'bingbase') {
/* BSMITHER ADDED TO OMIT OUT OF STOCK */
$query = sprintf('SELECT I.* FROM %1$sCubeCart_inventory AS I LEFT JOIN %1$sCubeCart_category AS C ON I.cat_id = C.cat_id WHERE I.status = 1 AND I.stock_level > 0', $GLOBALS['config']->get('config', 'dbprefix'));
$results = $GLOBALS['db']->query($query, $per_page, $page);
if ($results === false) $results = array();
 /* END BSMITHER ADDED TO OMIT OUT OF STOCK */
	$header_fields = array('id', 'product_type', 'b_category', 'link', 'title', 'description', 'image_link', 'price', 'condition', 'shipping_weight', 'upc', 'ean', 'jan', 'isbn', 'availability', 'brand', 'gtin', 'mpn');
	$fields  = array('product_id', 'store_category', 'google_category', 'url', 'name', 'seo_meta_description', 'image', 'price', 'condition', 'product_weight', 'upc', 'ean', 'jan', 'isbn', 'availability', 'manufacturer', 'gtin', 'mpn');
	$delimiter = "\t";
	$extension = 'txt';
	$glue  = "\r\n";
	$field_wrapper = '"';
	$field_keys_to_wrap = array('description');
	$image_path = 'url';
    $image_mode = 'source';
    $feed_file_name = CC_ROOT_DIR . '/FEEDS/plushbingbase.txt';}
/* IMAGE AND FEED ARE BSMITHER EDITS */

 

Edited by Dirty Butter
Link to comment
Share on other sites

According to your arrays, the $fields element name is associated with the $header_fields element title.

So, you need title to be seen as:

name - condition

Without customizations to the core code, the dash will be problematic. But, since this is only you, and this is only one column in the report, we may just go ahead and do this for your store.

To start:

Find:
$fields  = array('product_id', 'store_category', 'google_category', 'url', 'name', 'seo_meta_description', 'image', 'price', 'condition', 'product_weight', 'upc', 'ean', 'jan', 'isbn', 'availability', 'manufacturer', 'gtin', 'mpn');

Change just:
'name'
To:
'name condition'

That is, we just grouped two (or more) data items together. The code will split the columns into parts by the space, figure out the real data of each column part, then join the real data parts together using a space.

In /admin/sources/products.export.inc.php, find near line 126 (in CC608):\
$result[$field] = implode(' ', $formatted_field);

Change to:
$result[$field] = implode(' - ', $formatted_field);

The space-dash-space is now the glue that strings together the elements of this array.

Link to comment
Share on other sites

"used" is lowercase because it is a "key" that associates the actual language phrase:

['common']['new'] = "New" in English, etc.
['common']['used'] = "Used" in English, etc.
['common']['refurbished'] = "Refurbished" in English, etc.

There are only a couple of array elements in the export that contain locale-specific info: the SEO path is locked to the default language of the store, and the formatted price is locked to the default currency of the store.

So, nothing else being able to be 'adjusted' for a targeted export, it stands to reason that there is no means to 'adjust' any other column's actual data to reflect the locale.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...