niccol:
But the logic is really about upgrades and future alterations.
I've never found this to be an issue, at least not as far as the database is concerned.
niccol:
For instance, if someone tries to revert to a back-up version of the products table, which may or may not have the added column, then they will experience issues.
But on the same token, this situation will still exist even if a new table were created.
niccol:
I am sure you can think of other examples just as well as me, remembering, of course, that you do not know for sure that the developers may in the future choose to make alterations of their own to the products table ( probably not but who knows? )
I can only think of one case where it could cause a problem (something I was very concerned about in the early days of development), and that is in the case where php/sql code uses the 'select *' syntax and expects a specific number of fields in a specific order. Thankfully none of the ZenCart code uses thins method.
niccol:
For me it is mainly a conceptual choice to keep the module as separate from the core as possible. In Zen, as I know you know, that is kind of hard to do with regard to files.
Now this is a cause of many problems especially in regards to upgrades and backup restores, but the problems will be the same no matter which method is used.
niccol:
The developers I know are working on a proper plug-in architecture for a future version which hopefully will make that easier.
I seem to recall ZenCart V2 is planned to provide dimensional support, and I think I've seen or read something somewhere that they'll also be using a separate table to hold this data, which is another reason why I opted to pick your brains. :)
niccol:
With the database there just seems no good reason to mix the module bits in with the core bits. Why not keep them separate?
The 'good reason' I had (besides not having to re-invent the wheel) was for the sheer simplicity of the modification needed to the core code to make use of the additional DB fields.
niccol:
It may not solve many issues for users but even if it solves a couple then that is great. Also the clarity it provides about 'what does what' is just good practice, I reckon.
Seriously, the only problem that I'm aware of is the situation whereby the database has been restored from an older version (without the extra fields), but the core php files hadn't been restored.. in which case it aborts with an undefined field error. If a new table was created instead, this same condition will produce an unknown table error.
In the 'opposite' case where the .php files are restored from a backup (or overwritten due to an upgrade), the only problem is the module that uses dimensional data will fail to work, everything else will work as normal (no errors, even though the additional fields still exist).
niccol:
It is not a really major point, for sure, but I don't think I am alone in this belief. I can think of a couple of multi-module authors who have expressed the same views.
I have to admit, that this was my preferred option too, and if it hadn't been for the existing Canada Post module (and the fact that the weight data is also stored in the products table) I probably would have even gone that way... Clearly I took the 'easy' solution rather than my 'preferred' solution, but I've not regretted that decision (In other words, It hasn't been the cause of any support queries or any other problem).
The thing is, I don't know/remember why the addition of the new table was my preferred option, and since the 'easy' option hasn't caused any problems that I know of (that wouldn't have occurred with a new table method), I was hoping for a bit of a fresher course :)
niccol:
Strangely, I just yesterday, had a look at Delia's module that adds extra fields to the product. http://www.zen-cart.com/downloads.php?do=file&id=926 . I was really happy to see that she had taken the separate table approach. So much so that I used the mod rather than coding what I wanted :-) Saved the client an hour of my time. So that is something that the OP might look at too.
For sure. However, I loved the way you were thinking 'outside the box' with your suggestion "You can just abuse the 'weight' slot in the database. You can hide the weight information from the front end and just use weight to equal length".
If the product weight isn't going to be used anywhere, and the OP is only interested in the product length then this 'unusual' method would be the one I would go for, simply for the sheer simplicity of it.
Cheers
Rod
NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.
Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.