Jump to content
Sign in to follow this  
aspiringdeveloper

Mod in progress- grid attributes

Recommended Posts

I hate to double post but in the installation & configuration forum I am not getting much help. this topic http://forums.oscommerce.com/index.php?showtopic=298652 is more of a core development issue. If a seaoned php developer can please read the thread (only 8 posts) it would really help me out.

 

Basically my proposed mod adds a few new tables. : grid_attibutes, grid_row_col.

 

Some products will have grid atributes which basically mean an an entry in the grid_attibutes table for each row/col cell in the table. The table will have prices shown.

 

To illustrate: I sell pet food in various flavours and various bag sizes. Its foolish to set up an individual attribute for each flavour-size combination. * although I could do that and it would work fine *. I rather have all my food displayed in a table for a particular brand (where brand represents 1 entry in the products table).

 

Long sotry short: Adding new tables gets to the core of the product. I may have to make many logic branches in the shopping_cart class, the product_info.php file etc etc.

 

I need to understand in some kind of flow chart high level way the mechanisms behind product attributes and how product attributes gets assigned to the shopping_cart class. Basically, I am starting very slowly to understand some of the mechanisms by reverse engineering. But this is a slow and error prone way to about it.

 

There must be in the hands of some developers some form of planning chart or diagram showing how each piece of the puzzle fits together. I've gone through the enclosed 114 page documentation, which has some noce suggestions of customizations but only on a superficial level. I really need to get into the meat and bones of oscommerce and for that I need to understand more about how the oscommerce logic is put together.

 

In particular: what are the mechanisms of a user adding an attribute--> getiing that attribute assigned to the class--> Basket table updated--> convert to order etc. I'll need to mirror the same logic for my grig_attibutes.

 

Thanks in advance. I hope someone can help me to help improve oscommerce.

Share this post


Link to post
Share on other sites

I know exactly what you mean. I've spend a lot of time searching for documentation as the sourcecode (let alone others' contribs) are not commented. I'm by no means a hard core developer and only dived right into this because I had no choice. I would start a wiki for developers but v3 is around the corner so I guess v2.2 will be phased out soon.

 

I can only help you with your first question: how are attributes stored. In a post on the mysql forum I've made an illustration of how the products and attributes relate to each other and has helped me greatly to understand how the database is set up.

 

the header is the table name with the columns as subheaders:

 

DatabaseAttributeOverzicht.gif

 

I've highlighted with colors which ID's match in each table. You can see that the products table has a matching products_id in products_attributes. Each product can have multiple attributes assigned, stored in each row of the products_attributes table. So there can be more than one products_id in the attrib table. please see myphpadmin (if your host supports this tool) and look in the database.

 

The designers made a mistake in naming ID's as in the products_attributes table there's a options_id and options_values_id, which matches with the differently named products_options_id and products_options_values_id. I didn't know that at the time I made the illustration.

 

The products_options_id describe the group name of an attribute (like color) and products_options_values_id describes the kind of attribute, like blue, red or orange. ID's are of course numbers only, each table (products_options and products_options) also contains a name field which has a string.

 

When an attribute is assigned/added to a product, a new row is added to the products_attributes table, when an attribute is removed, the row is removed also. There's no enabled/disabled toggle as one would expect, although this is much more efficient space wise, it can be difficult to check which are present and which aren't.

 

I haven't touched the shopping cart yet, I can't comment on that but it would be best to print out the class (or use multiple monitors to lay source code side by side and go through it all, adding comments when certain parts are understood.

 

I hope version 3 will be better commented and documented. At least its more object oriented now so it should be easier to understand and extend.

 

Good luck!

 

I hate to double post but in the installation & configuration forum I am not getting much help. this topic http://forums.oscommerce.com/index.php?showtopic=298652 is more of a core development issue. If a seaoned php developer can please read the thread (only 8 posts) it would really help me out.

 

Basically my proposed mod adds a few new tables. : grid_attibutes, grid_row_col.

 

Some products will have grid atributes which basically mean an an entry in the grid_attibutes table for each row/col cell in the table. The table will have prices shown.

 

To illustrate: I sell pet food in various flavours and various bag sizes. Its foolish to set up an individual attribute for each flavour-size combination. * although I could do that and it would work fine *. I rather have all my food displayed in a table for a particular brand (where brand represents 1 entry in the products table).

 

Long sotry short: Adding new tables gets to the core of the product. I may have to make many logic branches in the shopping_cart class, the product_info.php file etc etc.

 

I need to understand in some kind of flow chart high level way the mechanisms behind product attributes and how product attributes gets assigned to the shopping_cart class. Basically, I am starting very slowly to understand some of the mechanisms by reverse engineering. But this is a slow and error prone way to about it.

 

There must be in the hands of some developers some form of planning chart or diagram showing how each piece of the puzzle fits together. I've gone through the enclosed 114 page documentation, which has some noce suggestions of customizations but only on a superficial level. I really need to get into the meat and bones of oscommerce and for that I need to understand more about how the oscommerce logic is put together.

 

In particular: what are the mechanisms of a user adding an attribute--> getiing that attribute assigned to the class--> Basket table updated--> convert to order etc. I'll need to mirror the same logic for my grig_attibutes.

 

Thanks in advance. I hope someone can help me to help improve oscommerce.

Share this post


Link to post
Share on other sites
I know exactly what you mean. I've spend a lot of time searching for documentation as the sourcecode (let alone others' contribs) are not commented. I'm by no means a hard core developer and only dived right into this because I had no choice. I would start a wiki for developers but v3 is around the corner so I guess v2.2 will be phased out soon.

 

I can only help you with your first question: how are attributes stored. In a post on the mysql forum I've made an illustration of how the products and attributes relate to each other and has helped me greatly to understand how the database is set up.

 

the header is the table name with the columns as subheaders:

 

DatabaseAttributeOverzicht.gif

 

I've highlighted with colors which ID's match in each table. You can see that the products table has a matching products_id in products_attributes. Each product can have multiple attributes assigned, stored in each row of the products_attributes table. So there can be more than one products_id in the attrib table. please see myphpadmin (if your host supports this tool) and look in the database.

 

The designers made a mistake in naming ID's as in the products_attributes table there's a options_id and options_values_id, which matches with the differently named products_options_id and products_options_values_id. I didn't know that at the time I made the illustration.

 

The products_options_id describe the group name of an attribute (like color) and products_options_values_id describes the kind of attribute, like blue, red or orange. ID's are of course numbers only, each table (products_options and products_options) also contains a name field which has a string.

 

When an attribute is assigned/added to a product, a new row is added to the products_attributes table, when an attribute is removed, the row is removed also. There's no enabled/disabled toggle as one would expect, although this is much more efficient space wise, it can be difficult to check which are present and which aren't.

 

I haven't touched the shopping cart yet, I can't comment on that but it would be best to print out the class (or use multiple monitors to lay source code side by side and go through it all, adding comments when certain parts are understood.

 

I hope version 3 will be better commented and documented. At least its more object oriented now so it should be easier to understand and extend.

 

Good luck!

 

 

Thanks for your input. Yes I have already disected the table format used by the application. Your notes validate the same things I have discovered.

 

I am making my contribution extremely modular and totally object oriented. My goal is to make minimal changes to the existing code but rather instead add a couple of new class modules that get imported by application_top.php. This will make the mod portable so that when v3 comes out, I'll be able to adapt it.

 

I am trying to minimize the changes needed to the database table structure. I am only adding 2 new tables so that once again the mod will be easy to install to either v2 or v3 of oscommerce.

 

You raise a good point about documentation. I should start the project by documenting each class module. The most important class for me is the shopping_cart class. This class I will unfortunately need to add some new methods to support my grid object.

 

Thanks

Share this post


Link to post
Share on other sites
Thanks for your input. Yes I have already disected the table format used by the application. Your notes validate the same things I have discovered.

 

I am making my contribution extremely modular and totally object oriented. My goal is to make minimal changes to the existing code but rather instead add a couple of new class modules that get imported by application_top.php. This will make the mod portable so that when v3 comes out, I'll be able to adapt it.

 

I am trying to minimize the changes needed to the database table structure. I am only adding 2 new tables so that once again the mod will be easy to install to either v2 or v3 of oscommerce.

 

You raise a good point about documentation. I should start the project by documenting each class module. The most important class for me is the shopping_cart class. This class I will unfortunately need to add some new methods to support my grid object.

 

Thanks

 

 

 

I have good news to report. I have finished devopement of the first major milestone of the grid project. The mod now allows the shopper to add grid products to their shopping carts. The grid is table of href price links that trigger grid identifier for a product that is a member of a grid. The modification handles the row and column intersection and is able to direct the appication properly.

 

The bad news is that for now I am still testing and the only way to add grid information is through phpadmin. I still have to program the input interface now.

 

After that, the next challenge will be to contol the inventory quantities in the grid product list.

 

Still a lot of work to do.

 

PS- the modification so far has led to changes in about 6 files and 1 new file. I was hoping to minimize the changes but its proving to be a pretty major mod. I am not sure how easy it will be for members to simply install the mod. The installation may require a long list of copy-paste instructions to make the php script file changes. If I just upload new php scripts, people will overwrite their existing scripts and loose whatever other mods they have installed.

Edited by aspiringdeveloper

Share this post


Link to post
Share on other sites
I have good news to report. I have finished devopement of the first major milestone of the grid project. The mod now allows the shopper to add grid products to their shopping carts. The grid is table of href price links that trigger grid identifier for a product that is a member of a grid. The modification handles the row and column intersection and is able to direct the appication properly.

 

The bad news is that for now I am still testing and the only way to add grid information is through phpadmin. I still have to program the input interface now.

 

After that, the next challenge will be to contol the inventory quantities in the grid product list.

 

Still a lot of work to do.

 

PS- the modification so far has led to changes in about 6 files and 1 new file. I was hoping to minimize the changes but its proving to be a pretty major mod. I am not sure how easy it will be for members to simply install the mod. The installation may require a long list of copy-paste instructions to make the php script file changes. If I just upload new php scripts, people will overwrite their existing scripts and loose whatever other mods they have installed.

 

 

More good news :)

 

The administration of assigning grid products is complete. In products attributes, I have added a section for grid attributes. So the input interface is complete.

 

Next on the todo list:

 

Incorporate inventory controls, special pricing, some validation checks to add.

 

I have a question to you modders out there: Would you like me to release the partially finished mod as is for now while I continue to tweak it, or should I finish the tweaking first?

Share this post


Link to post
Share on other sites
More good news :)

 

The administration of assigning grid products is complete. In products attributes, I have added a section for grid attributes. So the input interface is complete.

 

Next on the todo list:

 

Incorporate inventory controls, special pricing, some validation checks to add.

 

I have a question to you modders out there: Would you like me to release the partially finished mod as is for now while I continue to tweak it, or should I finish the tweaking first?

 

Phew, finally all done. Where do I upload my contribution?

Share this post


Link to post
Share on other sites
Testing it now. Will feedback later on.

 

One quick comment- You'll see a create gid button at the top of the form for entering and editing products in the administration mode under products and categories. Once you drill down to an individual product where you would input the english and multilanguage product descriptions that is where you will find the create grid button.

 

Happy testing everyone. I am looking forward to your feedback.

Edited by aspiringdeveloper

Share this post


Link to post
Share on other sites
PHP5 only will turn a lot of users off.

 

Anyway, installed on localhost. What's the next step? I don't see any changes in products_attributes other than a blank dropdown with a submit button next to it...install is as per your files - I just overwrote the existing oscommerce files.

 

Maybe make a readme so that we can get an idea of what it does, how it works, how to insert a grid etc...

 

Sorry PHP 5 for now but probably a simple fix for later on. I am assuming most people use php5 by now..

 

See my comment above about the create grid button. A readme with pictures and more complete documentation will follow. PHP4 compatitablity should be a very easy fix but I can only do so much.. I still have a lot of work on my own website to do.

Edited by aspiringdeveloper

Share this post


Link to post
Share on other sites
PHP5 only will turn a lot of users off.

 

Anyway, installed on localhost. What's the next step? I don't see any changes in products_attributes other than a blank dropdown with a submit button next to it...install is as per your files - I just overwrote the existing oscommerce files.

 

Maybe make a readme so that we can get an idea of what it does, how it works, how to insert a grid etc...

 

Sorry PHP 5 for now but probably a simple fix for later on.

 

See my comment above about the create grid button. A readme with pictures and more complete documentation will follow. PHP4 compatitablity should be a very easy fix but I can only do so much.. I still have a lot of work on my own website to do.

 

EDIT:

 

Let me elaborate on the php5 compatibility:

 

For reasons of my own site stability, I don't want to be switching back and forth to php4 just to test. Therefor I propose to the mod community to look at the core class of my mod: grid.php. See what is in there that is php 5 specific and post back.

 

Next, in the catalog folder I made a small change to the Includes/application_top.php as well as the admin/Includes/application_top.php for registering the session variable for the grid class. I MAY have accidently used php 5 specific commands for that when there was no reason for it. I'll see If I can make that change. We are only talking 2-3 lines of code- not a big deal but I have no way to test.

 

The grid.php class file should be fine in terms of Php 4 compatibility.

Edited by aspiringdeveloper

Share this post


Link to post
Share on other sites
Sorry PHP 5 for now but probably a simple fix for later on.

 

See my comment above about the create grid button. A readme with pictures and more complete documentation will follow. PHP4 compatitablity should be a very easy fix but I can only do so much.. I still have a lot of work on my own website to do.

 

EDIT:

 

Let me elaborate on the php5 compatibility:

 

For reasons of my own site stability, I don't want to be switching back and forth to php4 just to test. Therefor I propose to the mod community to look at the core class of my mod: grid.php. See what is in there that is php 5 specific and post back.

 

Next, in the catalog folder I made a small change to the Includes/application_top.php as well as the admin/Includes/application_top.php for registering the session variable for the grid class. I MAY have accidently Lused php 5 specific commands for that when there was no reason for it. I'll see If I can make that change. We are only talking 2-3 lines of code- not a big deal but I have no way to test.

 

The grid.php class file should be fine in terms of Php 4 compatibility.

 

Well I've looked at the SESSION variables and everything is php4 /php5 compatible as far as I can tell. The only thing I can think of is that the way in which the class object is called is creating a confusion in php 4. The grid class itself is straight forward php4 /php 5 compatible.

 

Like I said, I am only able to confirm that my mod is php5 compatible but I am stumped as to why its not working in php4.

Edited by aspiringdeveloper

Share this post


Link to post
Share on other sites

This looks like it could be very useful - installed but all I get in the catalog is:

 

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /public_html/catalog2/includes/classes/grid.php on line 4

 

And in Admin->categories/products:

 

Fatal error: Call to undefined function: tep_hide_session_id() in /public_html/catalog2/admin/categories.php on line 780

 

In Admin->products attributes:

 

Fatal error: Call to a member function on a non-object in /public_html/catalog2/admin/products_attributes.php on line 36

 

Any ideas why?

 

Cheers for your time.

Share this post


Link to post
Share on other sites
This looks like it could be very useful - installed but all I get in the catalog is:

 

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /public_html/catalog2/includes/classes/grid.php on line 4

 

And in Admin->categories/products:

 

Fatal error: Call to undefined function: tep_hide_session_id() in /public_html/catalog2/admin/categories.php on line 780

 

In Admin->products attributes:

 

Fatal error: Call to a member function on a non-object in /public_html/catalog2/admin/products_attributes.php on line 36

 

Any ideas why?

 

Cheers for your time.

 

 

Are you using php4? Php 4 has some differences. Anyone have any ides?

Edited by aspiringdeveloper

Share this post


Link to post
Share on other sites
Are you using php4? Php 4 has some differences. Anyone have any ides?

 

Also did you make sure your configure.php files all point to your catalog2 new install? I hate to ask the obvious but just in case.

 

Another Idea: In the first 8 lines of the grid.php class are the variable decalations - public and protected.

 

Change the words 'public' for 'var'

 

IE:

public $currentpid;
public $currentlang;
public $heading;
public $gridtable;
protected $counter;
public $rowid;
public $colid;
public $gridarr;
...

 

 

Becomes:

 

var $currentpid;
var $currentlang;
var $heading;
var $gridtable;
var $counter;
var $rowid;
var $colid;
var $gridarr;
...

Edited by aspiringdeveloper

Share this post


Link to post
Share on other sites

I provided some screen shots in the contributions link. Remember to access grid attributes you first need to define a grid in the products screen for the product of interest.

Share this post


Link to post
Share on other sites

I can't over emphasize-When you run it for the first time, you NEED to create the grid in the in the Admin->categories/products.

The first time the grid is initialized, it creates two new tables for you but you must initialize them with the Create Grid button first in Admin->categories/products before going to Admin->products attributes.

Edited by aspiringdeveloper

Share this post


Link to post
Share on other sites

So any news yet? I need someone to get this working and post a success story to serve as a catalyst for others to start downloading. I really believe this to be the next evolution in attributes.

 

 

The new version 1.0 I uploaded is a complete package with the changes discussed in the thread that hopefully fixes the php4 compatibility. I'll start working on an installation guide for people wishing to install the mod piece-meal style- ie patching manually the changed files. This is important for people that don't want to thrash their entire heavily modded installation with my modded files. EG- instead of replacing application_top.php with my modded application_top.php, you would instead be instructed to copy specific text to the file.

 

 

In the meantime, if you have a test bed catalog with a virgin R2.2, then its worth giving this a try. I need some testimonials from people to get this ball rolling. In addition, if its not working for you you, I need to know ASAP so that we can fix the problem.

Edited by aspiringdeveloper

Share this post


Link to post
Share on other sites
So any news yet? I need someone to get this working and post a success story to serve as a catalyst for others to start downloading. I really believe this to be the next evolution in attributes.

 

 

The new version 1.0 I uploaded is a complete package with the changes discussed in the thread that hopefully fixes the php4 compatibility. I'll start working on an installation guide for people wishing to install the mod piece-meal style- ie patching manually the changed files. This is important for people that don't want to thrash their entire heavily modded installation with my modded files. EG- instead of replacing application_top.php with my modded application_top.php, you would instead be instructed to copy specific text to the file.

 

 

In the meantime, if you have a test bed catalog with a virgin R2.2, then its worth giving this a try. I need some testimonials from people to get this ball rolling. In addition, if its not working for you you, I need to know ASAP so that we can fix the problem.

 

 

You guys need to help me out here. Nobody told me that php4 doesn't support 'public function' in classes. Anyway, V1.1 uploaded should fix that.

 

All my knowledge about php is coming from books I read on Php5, which I assumed everyone was using.

 

Someone please post me a success story besides me. Its working for me that's for sure.

 

http://addons.oscommerce.com/info/5959

Edited by aspiringdeveloper

Share this post


Link to post
Share on other sites
You guys need to help me out here. Nobody told me that php4 doesn't support 'public function' in classes. Anyway, V1.1 uploaded should fix that.

 

All my knowledge about php is coming from books I read on Php5, which I assumed everyone was using.

 

Someone please post me a success story besides me. Its working for me that's for sure.

 

http://addons.oscommerce.com/info/5959

 

Am I talking to myself or what??

Share this post


Link to post
Share on other sites

I think it a great adea, something I can really us on my site. I'm trying on a virgin R2.2 test site, before installing on my site. Its running on php4 it set "Current row label:" and "Current col label:" and all I get is a blank drop down menu, How can I edit? how can't make it to work? I switch to php5 and when I set "Current row label:" and "Current col label I get error messages:

 

Warning: Invalid argument supplied for foreach() in /hermes/bosweb/web281/b2813/ipw.mssigns/public_html/catalog/admin/includes/classes/grid.php on line 553

 

Warning: Invalid argument supplied for foreach() in /hermes/bosweb/web281/b2813/ipw.mssigns/public_html/catalog/admin/includes/classes/grid.php on line 559

 

Warning: Invalid argument supplied for foreach() in /hermes/bosweb/web281/b2813/ipw.mssigns/public_html/catalog/admin/includes/classes/grid.php on line 592

 

Warning: reset() [function.reset]: Passed variable is not an array or object in /hermes/bosweb/web281/b2813/ipw.mssigns/public_html/catalog/admin/includes/classes/grid.php on line 598

 

Warning: Invalid argument supplied for foreach() in /hermes/bosweb/web281/b2813/ipw.mssigns/public_html/catalog/admin/includes/classes/grid.php on line 600

 

Warning: Invalid argument supplied for foreach() in /hermes/bosweb/web281/b2813/ipw.mssigns/public_html/catalog/admin/includes/classes/grid.php on line 609

 

Warning: reset() [function.reset]: Passed variable is not an array or object in /hermes/bosweb/web281/b2813/ipw.mssigns/public_html/catalog/admin/includes/classes/grid.php on line 615

 

Warning: Invalid argument supplied for foreach() in /hermes/bosweb/web281/b2813/ipw.mssigns/public_html/catalog/admin/includes/classes/grid.php on line 617

 

I Know notting about php! I did the installation in php4, can this be the problem?

Share this post


Link to post
Share on other sites
The reason why you are getting little feedback is because the contribution is unintuitive & hard to understand.

 

The 1st thing I mentioned was "it's PHP5 only" - as the developer of the contribution I assumed (wrongly it seems) that you knew you had coded this for 5 only.

 

Anyway - when you eventually write a proper readme/howto, you'll get lots more feedback. Most people here just run a live store - and who wants to add this to a live store just to see if it works?

 

First of all, I posted a how to update the require files so that the user doesn't need to replace application_top.php but can have more control by applying the patch manually.

 

Secondly, I assumed wrongly myself that most people are using php5 but honestly I was so deep into the coding that I had forgotten to consider that some may prefer php4 therefore I had to re-work the code.

 

 

Third, I want feedback because then I know people are trying it and I can see if there are improvements to make. I am still waiting for someone to try it and post back.

Share this post


Link to post
Share on other sites
...

 

I Know notting about php! I did the installation in php4, can this be the problem?

 

 

Good question. My knowledge is php5 and I am hoping for someone to point out where the non-backward compatible commands are. Does php4 use the foreach statement? I thought so but I notice none of the default files in oscommerce use foreach.

 

Make sure also you're using the latest grid.php file. See version 1.2 uploaded. In the earlier version I had some offending commands (public function.. not supported in php4). Make sure you don't see the words 'public function' anywhere in the grid.php file (*both in catalog/includes/classes and in admin/includes/classes*).

 

 

If you already did it in php4 then stick to php4 - don't switch back and forth.

 

Regarding editing the drop down row label, column label- see the documentation I uploaded. See my post above.

Edited by aspiringdeveloper

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×