Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

The Feedmachine Solution


lech

Recommended Posts

I am using Mindsparx admin so what to do with:

 

4. Modify admin/includes/column_left.php in your osC installation as follows.

 

Add this line:

 

require(DIR_WS_BOXES . 'feedmachine.php');

 

immediately below the line:

 

require(DIR_WS_BOXES . 'tools.php');

Link to comment
Share on other sites

Hi Misa,

 

This step isn't an absolute must. Instead you can just bookmark the Feedmachine Admin area (http://yoursite/admin/feedmachine_admin.php) in your browser and access it directly.

 

I'm not familiar with Mindsparx admin, but there might be an easy way for you to add a link to Feedmachine Admin in one of the menus.

 

All the best,

 

Lech

Link to comment
Share on other sites

You need to change this setting in the feed configuration file of the feed you want to modify, e.g. fm-feed-configs/google-simple.php. This setting is defined per feed configuration.

 

You need to have a Feedmachine Configuration file for every feed you want to generate. The google-simple configuration included in this contribution includes some notes about creating configurations.

 

I have uploaded a few other configurations (search the add-ons section for "Feedmachine Configuration") and I will add a few more shortly.

Link to comment
Share on other sites

Lech,

 

I keep getting a TEP STOP with 1064 error as below. This happens whenever I click the Generate Feeds button on the Google sample script. It was working fine until I clicked the Update button. Now it always fails.

 

I had this problem on FeedMachine 5.00, then wiped that install and installed this revised version. Same problem. I've run the SQL via your PHP installer and manually via admin tool.

 

Using MySQL 5.0.77 on Apache, OSC 2.2RC2a

 

Problem appears to be in lines 293-304, in /admin/feedmachine.php

 

I also notice that the "Language" dropdown is empty. I wonder if that is the problem. Perhaps $languages_list is empty and that may be screwing up the SQL syntax. My store has multiple languages, and it seems to me that at least the default lang should be picked up regardless.

 

languages array built
currencies array built
taxes array built
countries array built
categories array built
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')
						    AND p.products_status = 1
						  ORDER BY p.products_id' at line 9

SELECT COUNT(*) as count
                             FROM products p LEFT JOIN products_description pd ON p.products_id = pd.products_id
						                  LEFT JOIN manufacturers m ON p.manufacturers_id = m.manufacturers_id
								          LEFT JOIN manufacturers_info mi ON m.manufacturers_id = mi.manufacturers_id AND pd.language_id = mi.languages_id
						                  LEFT JOIN products_to_categories ptc ON pd.products_id = ptc.products_id
										  LEFT JOIN specials s ON ptc.products_id = s.products_id
										  LEFT JOIN categories c ON ptc.categories_id = c.categories_id
										  LEFT JOIN categories_description cd ON c.categories_id = cd.categories_id AND pd.language_id = cd.language_id
						  WHERE pd.language_id IN()
						    AND p.products_status = 1
						  ORDER BY p.products_id

Edited by Richard Cranium
Link to comment
Share on other sites

I am using Mindsparx admin so what to do with:

 

4. Modify admin/includes/column_left.php in your osC installation as follows.

 

Add this line:

 

require(DIR_WS_BOXES . 'feedmachine.php');

 

immediately below the line:

 

require(DIR_WS_BOXES . 'tools.php');

 

Misa,

 

I also use MindSparx 2.0. Try this:

 

1. Add this line in /admin/includes/boxes/tools.php (or whichever dropdown you want to place the FeedMachine link into). Just make sure it's in the middle of the drop down menu items:

 

                                   '<a href="' . tep_href_link(FILENAME_FEEDMACHINE) . '" class="menuBoxContentLink">' . BOX_FEEDMACHINE . '</a>' .

 

 

2. Add this line to the end of /admin/includes/filenames.php (before the last ?>):

 

// Feed Machine
 define('FILENAME_FEEDMACHINE', 'feedmachine_admin.php');

 

 

3. If installed, remove the file /admin/includes/boxes/feedmachine.php

 

David

Edited by Richard Cranium
Link to comment
Share on other sites

What version of php are you using?

 

Try this: delete the table from the database, go to Feedmachine Admin, click "Generate and Upload Feeds Now". Do not update before hitting the button. Let me know if this works. It will help narrow down the problem.

 

Lech,

 

I keep getting a TEP STOP with 1064 error as below. This happens whenever I click the Generate Feeds button on the Google sample script. It was working fine until I clicked the Update button. Now it always fails.

 

I had this problem on FeedMachine 5.00, then wiped that install and installed this revised version. Same problem. I've run the SQL via your PHP installer and manually via admin tool.

 

Using MySQL 5.0.77 on Apache, OSC 2.2RC2a

 

Problem appears to be in lines 293-304, in /admin/feedmachine.php

 

I also notice that the "Language" dropdown is empty. I wonder if that is the problem. Perhaps $languages_list is empty and that may be screwing up the SQL syntax. My store has multiple languages, and it seems to me that at least the default lang should be picked up regardless.

 

languages array built
currencies array built
taxes array built
countries array built
categories array built
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')
						    AND p.products_status = 1
						  ORDER BY p.products_id' at line 9

SELECT COUNT(*) as count
                             FROM products p LEFT JOIN products_description pd ON p.products_id = pd.products_id
						                  LEFT JOIN manufacturers m ON p.manufacturers_id = m.manufacturers_id
								          LEFT JOIN manufacturers_info mi ON m.manufacturers_id = mi.manufacturers_id AND pd.language_id = mi.languages_id
						                  LEFT JOIN products_to_categories ptc ON pd.products_id = ptc.products_id
										  LEFT JOIN specials s ON ptc.products_id = s.products_id
										  LEFT JOIN categories c ON ptc.categories_id = c.categories_id
										  LEFT JOIN categories_description cd ON c.categories_id = cd.categories_id AND pd.language_id = cd.language_id
						  WHERE pd.language_id IN()
						    AND p.products_status = 1
						  ORDER BY p.products_id

Link to comment
Share on other sites

What version of php are you using?

 

Try this: delete the table from the database, go to Feedmachine Admin, click "Generate and Upload Feeds Now". Do not update before hitting the button. Let me know if this works. It will help narrow down the problem.

 

Yes, that worked for the first pass.

 

PHP version 5.1.6

 

BTW, I noticed (from a bit of diagnosing) that $languages_row is empty (lines 200-207 in feedmachine.php). I still wonder if the languages being blank is the problem. $languages is = to "Array" (i.e. also empty, as you'd expect since $languages_row is empty).

 

Thanks for your help, btw.

 

Regards,

David

Link to comment
Share on other sites

I also notice that the "Language" dropdown is empty. I wonder if that is the problem. Perhaps $languages_list is empty and that may be screwing up the SQL syntax. My store has multiple languages, and it seems to me that at least the default lang should be picked up regardless.

 

Only just saw this part (must have been put in in the edit). The language dropdown should not be empty. Are the other menus loading correctly?

 

It would be good to get to the bottom of this, but in the mean time editing your configuration file(s), adding the following...

 

'language_id' => *

 

(Where * is the integer id of the language you want to use.)

 

... to the configuration array should be a workaround for the problem.

Link to comment
Share on other sites

Only just saw this part (must have been put in in the edit). The language dropdown should not be empty. Are the other menus loading correctly?

 

It would be good to get to the bottom of this, but in the mean time editing your configuration file(s), adding the following...

 

'language_id' => *

 

(Where * is the integer id of the language you want to use.)

 

... to the configuration array should be a workaround for the problem.

 

Which configuration file? The sample (Google Simple)? And if so, where?

Edited by Richard Cranium
Link to comment
Share on other sites

The SQL error is definitely caused by $languages_list array being empty.

 

I am playing around with some other ways to gather the language data. I noticed that for some odd reason functions in admin/includes/general.php called within feedmachine.php are ignored, as if they are not loaded. Seems odd to me and that this should not happen. Perhaps something related to opening a blank window to display the results (?). I'm not sure.

 

I'm continuing to play with it and see if I can get it to work. I can pull the store languages by manually adding function tep_get_languages() and mimicing the behavior in admin/includes/header.php to get the list of language id's and codes. Not ideal, but an experiment atm.

 

It's very confusing for me to follow the arrays in your code, so if you have some ideas I would prefer to use yours. Otherwise, for my needs I'll probably set the language list to all store languages just to make it work, or require only one see if I can get the drop-down language menu to work so the admin has to manually run each language file separately.

 

This problem must tie together somehow with the feedmachine_admin.php dropdown not working either.

 

Seems strange all the way around. I wonder if there is something in my store or server config that is causing conflict. I noticed others have had similar problem, but not everyone.

 

Regards,

David

Link to comment
Share on other sites

Yes, that worked for the first pass.

 

PHP version 5.1.6

 

BTW, I noticed (from a bit of diagnosing) that $languages_row is empty (lines 200-207 in feedmachine.php). I still wonder if the languages being blank is the problem. $languages is = to "Array" (i.e. also empty, as you'd expect since $languages_row is empty).

 

Thanks for your help, btw.

 

Regards,

David

 

Thanks for the tip, I will give it a try

Link to comment
Share on other sites

Which configuration file? The sample (Google Simple)? And if so, where?

 

That's correct. Add the line

 

'language_id' => *,

 

above

 

'include_record_function' => ''

 

replacing * by the integer id of the language.

Link to comment
Share on other sites

Do the other drop-down menus (currency and country) load correctly in Feedmachine Admin?

 

You are correct that the SQL error is caused by $languages_list being empty, but I am trying to work out the root of the problem: why the languages array is not loading correctly.

 

The interesting thing is that the languages are loaded in virtually the same way in both feedmachine.php and feedmachine_admin.php and in order for feedmachine to have worked at all, feedmachine.php must have loaded the languages array correctly at some point. But you mentioned that feedmachine.php wasn't loading the languages correctly. Could you verify this by adding

 

print_r($languages);

 

immediately after

 

//Build Languages Array
$languages = array();
$languages_query = tep_db_query('SELECT * FROM languages');
while( $languages_row = tep_db_fetch_array($languages_query) ) {
 $languages[ $languages_row['code'] ] = $languages_row;
}
tep_db_free_result($languages_query);
echo 'languages array built' . "\n";
ob_flush();

 

and letting me know what you get.

 

Also, could you copy and the paste the tep_get_languages function that you have. As standard this function loads languages in the same way that Feedmachine does - so hopefully this will give us some clue as to why it isn't working. (The one potentially significant difference is that Feedmachine uses the name of the languages table, 'languages', explicitly as oppose to the constant TABLE_LANGUAGES - something I will change in the upcoming version. However, if the table 'languages' did not exist then obviously that would have caused an error.)

 

Could you also check the contents of the languages table in your database and confirm that your languages are there.

 

The SQL error is definitely caused by $languages_list array being empty.

 

I am playing around with some other ways to gather the language data. I noticed that for some odd reason functions in admin/includes/general.php called within feedmachine.php are ignored, as if they are not loaded. Seems odd to me and that this should not happen. Perhaps something related to opening a blank window to display the results (?). I'm not sure.

 

I'm continuing to play with it and see if I can get it to work. I can pull the store languages by manually adding function tep_get_languages() and mimicing the behavior in admin/includes/header.php to get the list of language id's and codes. Not ideal, but an experiment atm.

 

It's very confusing for me to follow the arrays in your code, so if you have some ideas I would prefer to use yours. Otherwise, for my needs I'll probably set the language list to all store languages just to make it work, or require only one see if I can get the drop-down language menu to work so the admin has to manually run each language file separately.

 

This problem must tie together somehow with the feedmachine_admin.php dropdown not working either.

 

Seems strange all the way around. I wonder if there is something in my store or server config that is causing conflict. I noticed others have had similar problem, but not everyone.

 

Regards,

David

Link to comment
Share on other sites

By the way, if anyone wants to generate more than one version of a feed, they should just copy and rename the configuration file. This is applies for example where you want to have different language versions of the Google Product Search feed.

Link to comment
Share on other sites

Do the other drop-down menus (currency and country) load correctly in Feedmachine Admin?

 

Yes.

 

You are correct that the SQL error is caused by $languages_list being empty, but I am trying to work out the root of the problem: why the languages array is not loading correctly.

Me too! Seriously, great contrib. I am not very experienced in PHP so that is what's taking me so long to debug. Fairly complex code. Cool.

 

adding

 

print_r($languages);

 

and letting me know what you get.

 

Yes, thought of that before I read this post. Here's the result:

 

Array ( [0] => Array ( [id] => au [text] => au ) [1] => Array ( [id] => ca [text] => ca ) [2] => Array ( [id] => de [text] => de ) [3] => Array ( [id] => en [text] => en ) [4] => Array ( [id] => es [text] => es ) [5] => Array ( [id] => fr [text] => fr ) [6] => Array ( [id] => nz [text] => nz ) [7] => Array ( [id] => uk [text] => uk ) ) 

 

As you can see, it is actually filling the arrays. There are 8 languages and they're all there. So, that part works. The problem is it does not transfer to the dropdown menu, nor pre-populate anything.

 

The currencies and countries dropdowns work fine, yes.

 

I also checked DEFAULT_LANGUAGE, and it is "en" (as it should be).

 

 

Also, could you copy and the paste the tep_get_languages function that you have. As standard this function loads languages in the same way that Feedmachine does - so hopefully this will give us some clue as to why it isn't working.

 

Yes, it's the same func. Bizarre how it works when embedded in the file, but does not seem able to call the routine. Regardless, I'm focused on the admin file atm (feedmachine_admin.php) until I can figure out why the dropdown for languages is not working.

 

But here is the snippet you requested:

 

//Build Languages Array
 function tep_get_languages() {
   $languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");
   while ($languages = tep_db_fetch_array($languages_query)) {
     $languages_array[] = array('id' => $languages['languages_id'],
                                'code' => $languages['code']);
   }

   return $languages_array;
 }

 

(The one potentially significant difference is that Feedmachine uses the name of the languages table, 'languages', explicitly as oppose to the constant TABLE_LANGUAGES - something I will change in the upcoming version. However, if the table 'languages' did not exist then obviously that would have caused an error.)

 

Yes, I noticed that too. And currencies, etc. I was going to mention that but obviously you're aware of it. :)

 

Just in case, I tried using the pointer name, but it makes no difference. FM behaves the same.

 

 

Could you also check the contents of the languages table in your database and confirm that your languages are there.

 

It's setup properly, yes.

Edited by Richard Cranium
Link to comment
Share on other sites

Lech,

 

I may have found the source of the problem in the admin file. I noticed this peculiarity... $languages changes between the build langs code (lines 38-44 of the admin file) and when the drop down languages menu is created in line 166. I believe the problem is due to header.php being called. My admin header file sets up $languages for its own use. So, i am thinking if the variable name is changed in your files (i.e. to $languages_<something else>), perhaps it will start working. I was thinking of this a few days ago that maybe the variable names being the same are causing a conflict and something else you might want to change in a future version since $languages is used globally.

 

I'm going to try my hand at changing the variable name for $languages and see what happens.

 

Here is what my $languages var looks like just before the admin file tries to draw the admin drop down (note: this is actually one line of output, but I used CR's to make it easier to read on the forum):

 

Array ( 
[0] => Array ( [id] => 1 [name] => English (USA) [code] => en [image] => icon.gif [directory] => english ) 
[1] => Array ( [id] => 3 [name] => Español [code] => es [image] => mexico_icon.gif [directory] => espanol ) 
[2] => Array ( [id] => 4 [name] => Français [code] => fr [image] => icon.gif [directory] => french ) 
[3] => Array ( [id] => 2 [name] => Deutsch [code] => de [image] => icon.gif [directory] => german ) 
[4] => Array ( [id] => 9 [name] => Canada (English) [code] => ca [image] => icon_ca.gif [directory] => english_ca )
[5] => Array ( [id] => 8 [name] => Australia [code] => au [image] => icon_au.gif [directory] => english_au ) 
[6] => Array ( [id] => 11 [name] => New Zealand [code] => nz [image] => icon_nz.gif [directory] => english_nz ) 
[7] => Array ( [id] => 7 [name] => United Kingdom [code] => uk [image] => icon_uk.gif [directory] => english_uk ) 
)

 

As you can see, the 'id' field in the array changed from being equal to the languages 'code' to the 'languages_id' in the array. I'm sure this has got to be mucking things up somehow.

 

David

Edited by Richard Cranium
Link to comment
Share on other sites

*** One Bug Resolved ***

 

Yes, I was correct. I changed the $languages var name to $languages_fm and the feedmachine_admin.php file now works properly.

 

I'm still working on the 1064 SQL error in feedmachine.php. We'll see if it's related.

 

Either way, my advice is to change any $language or $languages variables to a unique name. If global variables are turned off it would be a non-issue, but with them on as seems to be common it has the potential to create such conflicts. I've also changed the SQL script references to pointers where appropriate (e.g. TABLE_LANGUAGES instead of languages; same with currencies, etc.).

 

I'll report back on the 1064 error if I find a solution.

 

As an example, my "build languages" code section in feedmachine_admin.php now looks like this:

 


 //Build Languages Array
 $languages_fm = array();
 $languages_query = tep_db_query('SELECT * FROM ' . TABLE_LANGUAGES . ' ORDER BY code');
 while( $languages_row = tep_db_fetch_array($languages_query) ) {
   $languages_fm[] = array('id'   => $languages_row['code'],
                        'text' => $languages_row['code']);
 }
 //

 

David

Edited by Richard Cranium
Link to comment
Share on other sites

*** SQL 1064 Error Resolved ***

 

I've got this solved now too with the problem in feedmachine.php. It seemed to work ok even with the $languages var (i.e. dup of the global variable), but I changed all instances to $languages_fm just in case. Also had to run it twice the first time, but it all works great now.

 

I would suggest as a new feature the ability to create duplicate feeds with different options, using the same feed config. For example, let's say that I need 2 feeds built off Google Simple config, one in English and one in Spanish, both in US Dollars. Right now I seem to have to do them one at a time, changing (updating) the config in the process. Or I can make a duplicate of the Google Simple config file, rename it, and run both at the same time. But if I wanted to do this frequently it seems to me that this would become tedious.

 

Perhaps this is possible and I just have not figured out how to do it with the current setup, but it does not seem possible to me atm.

Link to comment
Share on other sites

Well done for getting to the bottom of this. I'll make changes in the upcoming version. (By the way, the problem occurring in feedmachine.php was a direct consequence of no language being selected in Feedmachine Admin. feedmachine.php doesn't include any external code after the languages array is generated that could change it.)

 

I would suggest as a new feature the ability to create duplicate feeds with different options, using the same feed config. For example, let's say that I need 2 feeds built off Google Simple config, one in English and one in Spanish, both in US Dollars. Right now I seem to have to do them one at a time, changing (updating) the config in the process. Or I can make a duplicate of the Google Simple config file, rename it, and run both at the same time. But if I wanted to do this frequently it seems to me that this would become tedious.

 

I think it will be quite rare to need multiple versions of the same feed, so I think making copies of the configuration file is quite acceptable. Besides, there are small differences between the different language versions of the google feeds and having separate configuration files allows you to accommodate for these differences.

 

By the way, I'm afraid at the moment there is no Spanish version of Google Product Search. There are only UK, German and US versions.

Link to comment
Share on other sites

how can i make a feed to have this fields and to be in xml?

<Products>

<Product>bla bla</product>

<Manufacturer>xxxx</Manufacturer>

<Name>bla bla bla</Name>

<Product_Url>http://www.blabla.com</Product_Url>

<Image_url>http://www.blabla.com/images/bla.jpg</Image_url>

<Price>123</Price>

<category>bl;a bla bla</category>

<Description>more bla bla about the product</Description>

<Product_model>model of product</Product_model>

</Product>

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...