OSCOMMERCE SUPPORT CALL 702-453-3332

 

Help - Search - Members - Calendar
Full Version: Grid Attributes actually working
osCommerce Community Support Forums > osCommerce Online Merchant v2.x > Contributions / Add-Ons > Contribution Development
aspiringdeveloper
Due to some confustion about this contribution, I have created a new thread (see the old one for background information (http://forums.oscommerce.com/index.php?showtopic=299748)

Here is a screenshot




  1. Here is some documentation- installation and Usage. Modifications to existing OsC RC2 files is required. Please read pdf carefully
  2. Here is live proof it works
  3. Here is the download to the grid.php file (you will need to modify files as stipulated in step 1 and then extract grid.php to the indicated folders
  4. Download V1.1 from contributions for already edited files.


One note: Recommended PHP 5 until someone can confirm otherwise.


I need some feedback to make this better laugh.gif
Obviously the look of the grid itself needs work but at least the mechanics are all working.
aspiringdeveloper
There have been many alleged bugs bugs reported in the previous thread but none that I can reproduce.

The Grid works for me with the following setup:

osCommerce Online Merchant v2.2 RC2a
PHP Version: 5.2.4 (Zend: 2.2.0)
Database: MySQL 5.0.27-standard
Server OS: Linux 2.4.31
HTTP Server: Apache


If you are experiencing bugs, please specify in as much details the error and your setup.

Thank you
catalepticstate
Hi,
This contribution works ok.

When I installed it the errors that were given on the add product page where

Warning: Invalid argument supplied for foreach() in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 552

Warning: Invalid argument supplied for foreach() in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 558

Warning: Invalid argument supplied for foreach() in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 591

Warning: reset() [function.reset]: Passed variable is not an array or object in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 597

Warning: Invalid argument supplied for foreach() in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 599

Warning: Invalid argument supplied for foreach() in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 608

Warning: reset() [function.reset]: Passed variable is not an array or object in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 614

Warning: Invalid argument supplied for foreach() in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 616

Errors :3 :Need to set unique row and col
aspiringdeveloper
QUOTE (catalepticstate @ May 29 2008, 02:52 PM) *
Hi,
This contribution works ok.

When I installed it the errors that were given on the add product page where

Warning: Invalid argument supplied for foreach() in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 552

Warning: Invalid argument supplied for foreach() in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 558

Warning: Invalid argument supplied for foreach() in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 591

Warning: reset() [function.reset]: Passed variable is not an array or object in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 597

Warning: Invalid argument supplied for foreach() in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 599

Warning: Invalid argument supplied for foreach() in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 608

Warning: reset() [function.reset]: Passed variable is not an array or object in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 614

Warning: Invalid argument supplied for foreach() in H:\sokkit\site\cartgrid\admin\includes\classes\grid.php on line 616

Errors :3 :Need to set unique row and col



Yes this bug was reported before. I thought I had fixed it in the version 1.3 that is uploaded on my server however I may have missed a couple of lines please get Version 1.4 here.

You will not find it in the contributions section of the forum until I know for sure from you guys whether this is fixing the problem. Remmeber, PHP5 is not giving me an error so I rely on you guys to let me know and help me to better help you.


Explanation: The errors being produced seem to be caused by the foreach() not finding an iterable array.

To fix it I have basically added a trap for first checking that an array exists in $_POST['edit']['price'] with the if (is_array($pricedit)){
statement.

Try that fix if you haven't already. If it still gives the foreach() errror, then back to the drawing board.


CODE
$pricedit=$_POST['edit']['price'];
if (is_array($pricedit)){
foreach( $pricedit as $gid=>$price){
if (!is_numeric($price)){$price_error="ENTER NUMERIC PRICE"; $err=true; $error['price'][]=$gid;}
else{$query="UPDATE products_grid SET grid_values_price ='".$price."' WHERE products_grid_id = ". (int)$gid." LIMIT 1";
mysql_query($query);
}}}



A few other places I added the test ''if (is_array(..))''
aspiringdeveloper
QUOTE (aspiringdeveloper @ May 29 2008, 05:01 PM) *
Yes this bug was reported before. I thought I had fixed it in the version 1.3 that is uploaded on my server however I may have missed a couple of lines please get Version 1.4 here.




CODE
$pricedit=$_POST['edit']['price'];
if (is_array($pricedit)){
foreach( $pricedit as $gid=>$price){
if (!is_numeric($price)){$price_error="ENTER NUMERIC PRICE"; $err=true; $error['price'][]=$gid;}
else{$query="UPDATE products_grid SET grid_values_price ='".$price."' WHERE products_grid_id = ". (int)$gid." LIMIT 1";
mysql_query($query);
}}}



A few other places I added the test ''if (is_array(..))''



Shall I assume its working 100% now? Did the V1.4 grid.php fix help?
catalepticstate
Yes it did.
Just checking other bits out
QUOTE (aspiringdeveloper @ May 30 2008, 09:02 PM) *
Shall I assume its working 100% now? Did the V1.4 grid.php fix help?

catalepticstate
QUOTE (catalepticstate @ Jun 3 2008, 05:25 PM) *
Yes it did.
Just checking other bits out



Small issue with same name values, say you have "small" for two diff type attributes error msg =

1062 - Duplicate entry '14-1' for key 1

insert into products_options_values (products_options_values_id, language_id, products_options_values_name) values ('14', '1', 'small')
catalepticstate
QUOTE (catalepticstate @ Jun 9 2008, 04:13 PM) *
Small issue with same name values, say you have "small" for two diff type attributes error msg =

1062 - Duplicate entry '14-1' for key 1

insert into products_options_values (products_options_values_id, language_id, products_options_values_name) values ('14', '1', 'small')


Also, if I edit the grid price the page will reset the combo box for tax to "taxable goods" when orginally it was saved as "none"

Cannot change price either :-s

Can you send me your as a zip file?
aspiringdeveloper
QUOTE (catalepticstate @ Jun 9 2008, 03:19 PM) *
Also, if I edit the grid price the page will reset the combo box for tax to "taxable goods" when orginally it was saved as "none"

Cannot change price either :-s

Can you send me your as a zip file?


taxable good switching error: Does this happen only when you edit the grid data?

I am using the same grid.php as you are. The error could be in the integration with the categories.php file.
I am not getting the duplicate key error that you received. It must be another php4 thingy.


Can you be more specific? Were you in the products_attributes module or the categories module?

Entering the same description for 2 attributes is not a key violation. The tables do no use the description as primary keys. This error must be being caused by something else. Is there another attribute with the ID 14? Normally the system increments the attribute id # for each new attribute so that key violations don't occur. I'll keep an eye on that bug. In my first versions of the edits to the product_attributes.php, the attribute # got reset to 1 whenever the user switched to an empty option. I since fixed that.

Maybe there is an error somewhere in your edits to the product_attributes.php file? Possibly I made a typo in the readme. Try to use the pre-edited product_attributes.php that I uploaded. If that fixes the problem, then it means there is an error in the manual edit made to product_attributes.php.
aspiringdeveloper
Regarding the duplicate key error, I have been able to reproduce it only by brute force. The way in which I re-produced the error is not really a bug but merely the nature of session variables.

Let me explain:

When I am in product attributes and I create lets say the attribute 'small' for the option 'size'- the system assigns ID #14 for the the next available value option id key. If I then clear my internet cookies or otherwise force my session variables to expire, then try to go back to the exact same screen in product attribute then the script doesn't remember the last variable of 14 for the key. The system still thinks that the a value attribute last assigned was 13 and attempts to make a new 14 only to create a key error.

So far I haven't encountered the error through casual use but I'll keep my eye on it. Once again, I cannot test for php4 issues.

PS. Feel free to work on my source code to improve the contribution.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.