Dirty Butter Posted November 15, 2013 Share Posted November 15, 2013 Almost all of our products fall in the Toys & Games>Toys>Dolls, Playsets &Toy Figures>Stuffed Animals. Most o those that don't are dolls, and that category is not far from the Stuffed Animals category. So.... would it be possible to have that Category filled in by default, with the option of course to change it if necessary? I'm guessing it's a matter of putting a default value in the _inventory table instead of NULL. But I don't want to stop being able to choose from the whole list. Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 15, 2013 Share Posted November 15, 2013 In the admin template file products.index.php, find this near line 170: {foreach from=$GOOGLE_CATS item=cat}<option value="{$cat}" {if $cat==$PRODUCT.google_category && !empty($PRODUCT.google_category)}selected="selected"{/if}>{$cat}</option>{/foreach} Let's look at just this part: {if $cat==$PRODUCT.google_category && !empty($PRODUCT.google_category)}selected="selected"{/if} If the product already has a google_category, then make that option selected. We need to add the {else} part. After "selected", add just this: {elseif $cat=="Toys & Games>Toys>Dolls, Playsets & Toy Figures>Stuffed Animals"}selected="selected" Make sure your specific google_category is spelled correctly! This is the quick-n-dirty solution. A more flexible solution is to add an admin-settable choice (on the Store Settings, Stock tab?) which will serve as the default. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted November 16, 2013 Author Share Posted November 16, 2013 Thank you! That should be helpful for a large number of sellers. It probably should be included in CC as an admin-settable choice. Quote Link to comment Share on other sites More sharing options...
havenswift-hosting Posted November 16, 2013 Share Posted November 16, 2013 A more flexible solution is to add an admin-settable choice (on the Store Settings, Stock tab?) which will serve as the default. I also think that this would be a simple to add but valuable change - any chance it could be in the next release Al ? Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted November 16, 2013 Author Share Posted November 16, 2013 Make sure your specific google_category is spelled correct Just to emphasize, it's not just spelling, but spacing that has to be perfect, or it won't work. I tried typing it in, and it did not work. Copied it straight from a correct cpanel _inventory entry, and voila there it was, already filled in for me. Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 16, 2013 Share Posted November 16, 2013 "It's not just spelling, but spacing." In programming, spacing is also part of spelling. And in many cases, so is capitalization. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted November 18, 2013 Author Share Posted November 18, 2013 The quick n dirty way doesn't work properly when the category is NOT the default. Each time I Save & Reload while I'm creating the listing - it changes back to the default. I tried making the last change to the Google category, but it won't "stick" as a Doll, instead reverts to Stuffed Animal on Save. Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 18, 2013 Share Posted November 18, 2013 Please copy the line 170 that was edited as it exists in your file. Look in the database for this product immediately after a save of a category of your choice that is not the specified default. Please copy in your reply the databased value. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted November 19, 2013 Author Share Posted November 19, 2013 {if $GOOGLE_CATS} <select name="google_category" id="google_category" class="textbox" style="font-size: 10px;"> <option value="">{$LANG.common.please_select} …</option> {foreach from=$GOOGLE_CATS item=cat}<option value="{$cat}" {if $cat==$PRODUCT.google_category && !empty($PRODUCT.google_category)}selected="selected"{elseif $cat=="Toys & Games > Toys > Dolls, Playsets & Toy Figures > Stuffed Animals"}selected="selected"{/if}>{$cat}</option>{/foreach} </select> {else} <input name="google_category" id="google_category" class="textbox" type="text" value="{$PRODUCT.google_category}" maxlength="250" /> {/if} The database DOES show the correct choice, but only if a Save or Save&Reload is performed. At that point the Product listing in Admin shows the Default again. Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 19, 2013 Share Posted November 19, 2013 Interesting. Please try this: <option value="{$cat}" {if $cat == $PRODUCT.google_category && !empty($PRODUCT.google_category)}selected="selected" {elseif $cat == "Toys & Games > Toys > Dolls, Playsets & Toy Figures > Stuffed Animals"}selected="selected" {/if}>{$cat}</option> The only difference is that there are spaces on either side of the double equals signs. (Smarty syntax requirement.) Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted November 19, 2013 Author Share Posted November 19, 2013 Added spaces on both sides in two places, but still same results - saved in table, but not shown on Admin. Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 19, 2013 Share Posted November 19, 2013 Ah! I see what's going on. Be back shortly. Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 19, 2013 Share Posted November 19, 2013 Let's do this: <option value="{$cat}" {if $cat == $PRODUCT.google_category && !empty($PRODUCT.google_category)}selected="selected" {elseif empty($PRODUCT.google_category) && $cat == "Toys & Games > Toys > Dolls, Playsets & Toy Figures > Stuffed Animals"}selected="selected" {/if}>{$cat}</option> The change here is that if there is no current google_cat assigned to the product (empty($PRODUCT.google_category)) and also, if while working through the list, we happen upon the default google_cat, then make this option selected. Prior to this, the option list was getting two options selected: the product's actual google_cat (when iterating through the list got to this item):if $cat == $PRODUCT.google_category and always the default (when iterating through the list got to this item):elseif $cat == "Toys & Games > Toys > Dolls, Playsets & Toy Figures > Stuffed Animals" Thus, with two list options selected, the browser will always show the first selected (or last, depending on the browser). Working through the google list, we are looking at only one item at a time, and for each item, it will match either the first, the second, or neither. Earlier, the attempt was to code for $cat to be more than one thing at the same iteration. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted November 19, 2013 Author Share Posted November 19, 2013 I think I've lost track of what to change and what to leave as is. The page loads without Debug warning of issues, but the drop down box has no google choices. It's a black box just a few pixels wide. {if $GOOGLE_CATS} <select name="google_category" id="google_category" class="textbox" style="font-size: 10px;"> <option value="{$cat}" {if $cat == $PRODUCT.google_category && !empty($PRODUCT.google_category)}selected="selected" {elseif empty($PRODUCT.google_category) && $cat == "Toys & Games > Toys > Dolls, Playsets & Toy Figures > Stuffed Animals"}selected="selected" {/if}>{$cat}</option> </select> {else} <input name="google_category" id="google_category" class="textbox" type="text" value="{$PRODUCT.google_category}" maxlength="250" /> {/if} Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 20, 2013 Share Posted November 20, 2013 Here's the complete chunk of code: <div><label for="google_cat_code">{$LANG.catalogue.product_google_category}</label><span> {if $GOOGLE_CATS} <select name="google_category" id="google_category" class="textbox" style="font-size: 10px;"> <option value="">{$LANG.common.please_select} …</option> {foreach from=$GOOGLE_CATS item=cat} <option value="{$cat}" {if $cat == $PRODUCT.google_category && !empty($PRODUCT.google_category)}selected="selected" {elseif empty($PRODUCT.google_category) && $cat == "Toys & Games > Toys > Dolls, Playsets & Toy Figures > Stuffed Animals"}selected="selected" {/if}>{$cat}</option> {/foreach} </select> {else} <input name="google_category" id="google_category" class="textbox" type="text" value="{$PRODUCT.google_category}" maxlength="250" /> {/if} </span></div> Double check the spelling! Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted November 20, 2013 Author Share Posted November 20, 2013 As far as I can tell, it's working properly. The database is correct, the chosen non-default category shows properly, and a new product shows the default category properly. It looks like you've done it!!! So, if CC wanted to incorporate this, they would do something like create a Smarty expression for the chosen default, with an Admin place in Store Settings to designate the default? Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 20, 2013 Share Posted November 20, 2013 "Create a Smarty expression for the chosen default, with an Admin place in Store Settings to designate the default?" Correct. However, I would expect them to take the opportunity to "manage" this list from Google. It would be extremely easy to convert this string (really, really, really long string) into an xml file, only display the top levels in one drop-down, then ajax for the child levels. As each level is chosen, the "breadcrumbs", or "path" would be built up and displayed in the text field. The text field would display the existing/default choice when the highest level drop-down says "Please Select". I wish to draw Devellion's attention to this: http://www.celebird.com/news/pr-celebird-taxonomy-app.html Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted November 20, 2013 Author Share Posted November 20, 2013 It would be extremely easy to convert this string (really, really, really long string) into an xml file, only display the top levels in one drop-down, then ajax for the child levels. As each level is chosen, the "breadcrumbs", or "path" would be built up and displayed in the text field. The text field would display the existing/default choice when the highest level drop-down says "Please Select". This is EXACTLY the way Google used to do it themselves. It was SO much easier to use that way. Now you have to download the xml file from Google and search for what you need, if done from the Google site. Quote Link to comment Share on other sites More sharing options...
vidmarc Posted July 11, 2014 Share Posted July 11, 2014 Is there an SQL query that can be performed which will set default google listings? Quote Link to comment Share on other sites More sharing options...
G Dubyah Posted June 30, 2016 Share Posted June 30, 2016 Apologies for waking this up! I have edited my code to reflect the changes, and all seems to be OK and working fine, do I need to so through my inventory and "save" each product for this to work ? Quote Link to comment Share on other sites More sharing options...
bsmither Posted June 30, 2016 Share Posted June 30, 2016 Take a note of the Google category you have as default. Be extremely careful of the exact spelling and spaces. In admin, Maintenance, Query Database tab, look above the Query box. If there is a mention of a database table prefix pre_, be sure to use it as follows. Otherwise do not use the pre_: In the query box, enter: UPDATE pre_CubeCart_inventory SET `google_category` = "default-category-noted-earlier" WHERE `google_category` = ""; Note the names of columns are enclosed in backticks (above the tab key), not apostrophes. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.