Claudia M Posted August 1, 2021 Share Posted August 1, 2021 I have setup a few new columns fields whatever they are called) in the inventory table. Right now they show null if no data is added by my. Is there a way to just have it blank until I add the info? Not all products will have all the information. I must have set it up wrong Thanks in advance, Link to comment Share on other sites More sharing options...
bsmither Posted August 1, 2021 Share Posted August 1, 2021 The application is showing null because it was programmed that way. The application code could be rewritten to not show 'null' even if the value of that column in the database table is, in fact, null. Likewise, one can alter the database table schema so that a column must not hold a null, and must therefore default to a zero-length-string. (Using phpMyAdmin will make this alteration a very easy thing to do.) Please note there are some conceptual differences between null and a zero-length-string. Perhaps these differences make no difference to your needs. Link to comment Share on other sites More sharing options...
Claudia M Posted August 1, 2021 Author Share Posted August 1, 2021 what would the query be? Will it automatically change the product page to be blank or will I have to delete each null? I don't think the differences will matter to me. Link to comment Share on other sites More sharing options...
bsmither Posted August 1, 2021 Share Posted August 1, 2021 Which approach are you wanting to do? Change how nulls get displayed, or change the value that the database table is allowed to hold? Using phpMyAdmin, have it show the list of columns for the Cubecart_inventory table. For each column you need to change, uncheck the "Allow null" option, and for the default value, choose a string with nothing entered in the text entry field. The database engine might then automatically change the nulls to a zero-length-string. Or it might not. Or phpMyAdmin may report that altering the columns can't happen as long as there are rows with values that would become disallowed. I'm not sure. Once the changes to the database is finished, clear the cache, and then those data items ('Start', 'End') will show a zero-length-string. Link to comment Share on other sites More sharing options...
Claudia M Posted August 1, 2021 Author Share Posted August 1, 2021 This is what I have for redo_start. It still shows null on the product page even after clearing the caches. I tried the default "as defined" and left the box next to it blank. Still showed null. I haven't really started populating that field so if I have to setup a new one other that redo_start I can. Link to comment Share on other sites More sharing options...
bsmither Posted August 1, 2021 Share Posted August 1, 2021 All four of those images appear to be identical. In the Default column, is there a choice for a string? An empty string? Link to comment Share on other sites More sharing options...
Claudia M Posted August 1, 2021 Author Share Posted August 1, 2021 I don't know why the image posted so many times. Default column gives the following options: None (Will that show the word none - or leave it blank?) As defined: ( then you get the box) Null Current_timestamp Link to comment Share on other sites More sharing options...
bsmither Posted August 1, 2021 Share Posted August 1, 2021 In the Default column, choosing 'As Defined:' is a good choice. The text entry field that then appears would be left blank. All nulls should be converted to a blank string. Link to comment Share on other sites More sharing options...
Claudia M Posted August 1, 2021 Author Share Posted August 1, 2021 I tried that and the nulls remained. Maybe it doesn't automatically update? I'll create a new one with as defined and see what that does Link to comment Share on other sites More sharing options...
Claudia M Posted August 1, 2021 Author Share Posted August 1, 2021 I created a new one with default as defined and left it blank. Null still shows. Cleared the database and regular caches Link to comment Share on other sites More sharing options...
bsmither Posted August 1, 2021 Share Posted August 1, 2021 In phpMyAdmin, when at the "Browse" tab looking at the CubeCart_inventory table, for those rows that do not have an actual date in 'redo_start', does the cell show NULL or is it blank? Link to comment Share on other sites More sharing options...
Claudia M Posted August 1, 2021 Author Share Posted August 1, 2021 It is empty in the textbox on the actual product general information page. But it shows null on the product inventory page. This is where I want it blank. I'll look at what you just posted. Link to comment Share on other sites More sharing options...
bsmither Posted August 1, 2021 Share Posted August 1, 2021 CubeCart's admin does not use the cache, so changes made that get databased show in admin immediately. Link to comment Share on other sites More sharing options...
Claudia M Posted August 1, 2021 Author Share Posted August 1, 2021 The field is blank. Maybe on the Product Inventory page it has to show Null for some reason? Maybe my coding: <th nowrap="nowrap">{$THEAD.redo_start}</th> <td><span class="editable number" name="product[{$product.product_id}][redo_start]">{$product.redo_start}</span></td> <div><label for="redo_start">Redid / Start Date</label><span><input name="redo_start" id="redo_start" class="textbox number" type="text" value="{$PRODUCT.redo_start}" /></span></div> Link to comment Share on other sites More sharing options...
bsmither Posted August 1, 2021 Share Posted August 1, 2021 For the template you posted part of above, add at the end of that file this: {debug} This will have the browser popup a window showing the values of $product and the array that $product came from ($PRODUCTS?). What is the <div> statement doing? What is $PRODUCT.redo_start? I think the <div> block is where you are adding/editing data for a specific product. So, we won't worry about that. Link to comment Share on other sites More sharing options...
Claudia M Posted August 1, 2021 Author Share Posted August 1, 2021 I have the popup but I'm not sure what you are looking for Found it: begin => "" (originally redo_start but I changed it) Link to comment Share on other sites More sharing options...
Claudia M Posted August 1, 2021 Author Share Posted August 1, 2021 If I go into the actual edit the product page and put a space in the redo / Start box then it clears on the Product Inventory page - null gone; now blank. So I think this is probably the best that can be done. Link to comment Share on other sites More sharing options...
bsmither Posted August 1, 2021 Share Posted August 1, 2021 So: Was: <td><span class="editable number" name="product[{$product.product_id}][redo_start]">{$product.redo_start}</span></td> Now: <td><span class="editable number" name="product[{$product.product_id}][begin]">{$product.begin}</span></td> And the database column name has been changed from 'redo_start' to 'begin'. Or do you assign the query result 'redo_start' to the product array element 'begin' that is given to Smarty? Link to comment Share on other sites More sharing options...
Claudia M Posted August 1, 2021 Author Share Posted August 1, 2021 I created a new column name - begin - with different attributes: as defined, to see if a fresh start would help the null stuff on the product inventory page. It didn't. Null still shows on that page - null doesn't show on the actual product general information page Link to comment Share on other sites More sharing options...
bsmither Posted August 1, 2021 Share Posted August 1, 2021 That's strange. As you said, begin => "". Link to comment Share on other sites More sharing options...
Claudia M Posted August 1, 2021 Author Share Posted August 1, 2021 All 3 are in there redo_start => "" start => "" begin => " and end_expire => "" Link to comment Share on other sites More sharing options...
bsmither Posted August 1, 2021 Share Posted August 1, 2021 So, regardless of which you use for: {$product.whatever} in, for example: <td><span class="editable number" name="product[{$product.product_id}][begin]">{$product.begin}</span></td> the Smarty diagnostic window says it is a zero-length-string, but what gets displayed is null. That's crazy. Link to comment Share on other sites More sharing options...
Claudia M Posted August 2, 2021 Author Share Posted August 2, 2021 If we're talking about the same thing, the length is VARCHAR 50 and the default is as defined and blank box, per the image above. and it shows Null per the top image above while on the product general information page the input box is blank BUT if I put a space in the product general information input box then the Product Inventory Start field is blank Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.