Jump to content
traylor23

Additional Field Similar to Cubecart

Recommended Posts

Hey All,

   I have a baseball card site, ballcardz.com, and I'd like to add a searchable field in the admin, similar to the Product Code field, that I could enter a team name into, and it would show up in the product description right below the product code text. Anyone know what I need to do to accomplish this? Is there a 3rd party solution? I have searched as hard as I could before asking. Thanks in advance!

Share this post


Link to post
Share on other sites

If you are referring to the slide out search box, giving a text entry field for "Search Products", the keywords entered here are used in a simple LIKE fuzzy search against the 'name' or 'product_code' database table columns.

Can we assume you already have a database table column to hold 'team_name' in CubeCart_inventory? Or is this capability a third-party plugin? Or is this yet to be implemented?

There is no available hook to modify the WHERE expression when looking for the search word. So this part of the solution will be a hard-coded edit.

 

Share this post


Link to post
Share on other sites

Hey Brian,

  Basically what I am trying to do is to have a field in my admin, when I'm adding a product, similar to the product code box, where I can input a team name, and it show up underneath the product code on the storefront side on the product pages, like this:

Product Code: 89UDKGJ1RC

Team Name: Seattle Mariners

Also, it'd be nice if either the team name was a hyperlink to an aggregate page of every item under that team name, or searchable so that I could make one myself.

 

 

 

Share this post


Link to post
Share on other sites

Do you already make use of ALL the Miscellaneous Codes on the Product listing? It seems like it should be possible to use one of those, rename it, and edit the storefront code to display it where you want it.

Share this post


Link to post
Share on other sites

I am approaching this as wanting to associate a category to the product, then showing the category name.

I have to ask, How many team names will be needed? Will this get out of hand?

Discerning the name of the category would be easy enough. That is, if an item has a main category and also three associated categories, there would be the need to pick which associated category is to be displayed. (Answer: team categories would have it's parent category named "Team Name".)

You would then end up with a spot in the Category Navigation menu for "Team Name" (there's your link).

Share this post


Link to post
Share on other sites
2 hours ago, Dirty Butter said:

Do you already make use of ALL the Miscellaneous Codes on the Product listing? It seems like it should be possible to use one of those, rename it, and edit the storefront code to display it where you want it.

I did try that, but they do not show up on my product pages. Is there a way to make those codes display there. Renaming one of those, and having it show up would be the easier route, I think. Good suggestion!

7 minutes ago, bsmither said:

I am approaching this as wanting to associate a category to the product, then showing the category name.

I have to ask, How many team names will be needed? Will this get out of hand?

Discerning the name of the category would be easy enough. That is, if an item has a main category and also three associated categories, there would be the need to pick which associated category is to be displayed. (Answer: team categories would have it's parent category named "Team Name".)

You would then end up with a spot in the Category Navigation menu for "Team Name" (there's your link).

I'd rather not do it relative to another category. I've though of that, and I didn't like the process all that much (multiple categories for every item).  As far as number of teams, it would literally be ALL professional sports teams, so probably > 120.

Share this post


Link to post
Share on other sites

Could you perhaps use the `manufacturer` column for the team name? You could edit your language file to show 'Team Name' instead of 'Manufacturer'.

Otherwise, you'll need to add a column and edit your skin to display it, as well as tweak the admin files to allow you to edit / save and search by that field.

Share this post


Link to post
Share on other sites

I didn't think of that. I'll have to try and see if it works the way I need it to. Thanks for the suggestion.

***Only issue that I run into with that is with products that have more than one team featured.

Share this post


Link to post
Share on other sites

Allowing multiple teams for a single product is a more complicated question.

If you just want to allow users to search for said products using either of those team names, all you have to do is include them in the product description.

If you want to allow admins to filter products by those team names via the admin search bar, you're going to have to modify the search code to either:

  • Include the product description in the search (assuming you added the team names to the description)
  • OR include the manufacturer(s) column in the search

Choosing the second option introduces further complications, as by default CubeCart only supports one manufacturer per product; you'd probably need to make an additional table for the product:manufacturer associations in a one-to-many relationship, and then query that in your search as well as modify the admin product interface to allow setting multiple manufacturers.

If you are or have at your disposal a competent developer, the latter changes could be made in perhaps a few hours, more or less depending on how complicated it actually turns out to be.

Share this post


Link to post
Share on other sites

Let's say, for arguments sake, that I just wanted to duplicate the Product Code field and then change the name of that; is that possible?  Practical?

Share this post


Link to post
Share on other sites
10 minutes ago, traylor23 said:

Let's say, for arguments sake, that I just wanted to duplicate the Product Code field and then change the name of that; is that possible?  Practical?

By that do you mean add an additional column that has all the properties (e.g. searchability) of the original Product Code field? Sure, that's possible, but it boils down to the same amount of work as I was describing above - you still need to add the column, ability to edit it in the admin product panel, and modify all of the search code to include it.

Besides, how will adding that one additional column help your requirement for multiple team associations?

In other words, sure you can do it, but it will be just as much work as and less effective than creating a table for multiple associations.

Share this post


Link to post
Share on other sites
2 hours ago, traylor23 said:

I did try that, but they do not show up on my product pages. Is there a way to make those codes display there. Renaming one of those, and having it show up would be the easier route, I think. Good suggestion!

Getting the additional Codes to show on the store front shouldn't be too difficult. What skin do you use? What version CC are you on?

Share this post


Link to post
Share on other sites
50 minutes ago, bsandall said:

Allowing multiple teams for a single product is a more complicated question.

If you just want to allow users to search for said products using either of those team names, all you have to do is include them in the product description.

If you want to allow admins to filter products by those team names via the admin search bar, you're going to have to modify the search code to either:

  • Include the product description in the search (assuming you added the team names to the description)
  • OR include the manufacturer(s) column in the search

Choosing the second option introduces further complications, as by default CubeCart only supports one manufacturer per product; you'd probably need to make an additional table for the product:manufacturer associations in a one-to-many relationship, and then query that in your search as well as modify the admin product interface to allow setting multiple manufacturers.

If you are or have at your disposal a competent developer, the latter changes could be made in perhaps a few hours, more or less depending on how complicated it actually turns out to be.

 

22 minutes ago, bsandall said:

By that do you mean add an additional column that has all the properties (e.g. searchability) of the original Product Code field? Sure, that's possible, but it boils down to the same amount of work as I was describing above - you still need to add the column, ability to edit it in the admin product panel, and modify all of the search code to include it.

Besides, how will adding that one additional column help your requirement for multiple team associations?

In other words, sure you can do it, but it will be just as much work as and less effective than creating a table for multiple associations.

Yes....Does the "It works in my mind" reason become a sound theory?

6 minutes ago, Dirty Butter said:

Getting the additional Codes to show on the store front shouldn't be too difficult. What skin do you use? What version CC are you on?

Kurouto and 6.1.12

Share this post


Link to post
Share on other sites

I'm pretty sure this is from 6.0.12, but it should be close. This section of the admin skins products.index.php has all the references to the Codes:

<legend>{$LANG.catalogue.title_misc}</legend>
         <div><label for="upc_code">{$LANG.catalogue.product_upc}</label><span><input name="upc" id="upc" class="textbox" type="text" value="{$PRODUCT.upc}" maxlength="20"></span></div>
         <div><label for="ean_code">{$LANG.catalogue.product_ean}</label><span><input name="ean" id="ean" class="textbox" type="text" value="{$PRODUCT.ean}" maxlength="20"></span></div>
         <div><label for="jan_code">{$LANG.catalogue.product_jan}</label><span><input name="jan" id="jan" class="textbox" type="text" value="{$PRODUCT.jan}" maxlength="20"></span></div>
         <div><label for="isbn_code">{$LANG.catalogue.product_isbn}</label><span><input name="isbn" id="isbn" class="textbox" type="text" value="{$PRODUCT.isbn}" maxlength="20"></span></div>
         <div><label for="gtin_code">{$LANG.catalogue.product_gtin}</label><span><input name="gtin" id="gtin" class="textbox" type="text" value="{$PRODUCT.gtin}" maxlength="20"></span></div>
         <div><label for="mpn_code">{$LANG.catalogue.product_mpn}</label><span><input name="mpn" id="mpn" class="textbox" type="text" value="{$PRODUCT.mpn}" maxlength="20"></span></div>
	 <div><label for="brand_code">{$LANG.catalogue.product_brand}</label><span><input name="brand" id="brand" class="textbox" type="text" value="{$PRODUCT.brand}" maxlength="20" /></span></div>

I'll have to download kurouto to figure out what might work to show on the store front. Maybe someone else will be along who can tell you, as mine will be a slightly educated guess.

Try this in content.product.php in your Kurouto skin templates. I added an extra line for the upc code. Hopefully it shows.

<div id="product_description">
	  {$PRODUCT.description}
	<p><strong>{$LANG.catalogue.product_code}</strong>: {$PRODUCT.product_code}</p>
	<p><strong>{$LANG.catalogue.product_upc}</strong>: {$PRODUCT.upc}</p>
  </div>

 

Share this post


Link to post
Share on other sites

I was able to add the upc code line to my Foundation skin. But getting it Searchable means making some addition to catalogue.class.php so upc is included in the Search array. I do NOT know how to do that.

I've been toying with the idea of adding an extra search field for the Advanced Search that would select products by the predominant color, as well as my Search (NOT stock code at this time).

Share this post


Link to post
Share on other sites
1 minute ago, Dirty Butter said:

I was able to add the upc code line to my Foundation skin. But getting it Searchable means making some addition to catalogue.class.php so upc is included in the Search array. I do NOT know how to do that.

That's awesome! Thanks for testing it before I had the chance to! Maybe @bsmither can chime in for some ideas for that?

Share this post


Link to post
Share on other sites

MY code to show upc is different than what I suggested to you, as Foundation is coded differently than Kurouto. So you still need to test it with your Kurouto skin.

Share this post


Link to post
Share on other sites
4 minutes ago, Dirty Butter said:

MY code to show upc is different than what I suggested to you, as Foundation is coded differently than Kurouto. So you still need to test it with your Kurouto skin.

It worked fine as far as that side of things. Here is a screenshot after I changed the definitions.xml to reflect the new term.

success.jpg

Share this post


Link to post
Share on other sites

So the only thing left is to somehow add the 'upc' column (you have phrased as "Team") into a means for searching.

Amazingly enough, I just am finishing a project that searches for the UPC code.

However, there is a difference with that project your requirements: Even though you are using the UPC code to hold non-unique data, the UPC technology implies that every product has a unique UPC code. And that is what my project assumes.

So, I will explore making my project able to handle more than one product found when searching for UPC (you have phrased as "Team").

Share this post


Link to post
Share on other sites

I just used upc as an example as it was first in the list in admin. We don't have to provide a upc code, because everything we sell is used. But don't you provide UPC codes?

Don't make the change to Team in definitions.xml. Your change will be lost on upgrade. Find the Language section in admin, click on your flag, and look in Category. You can change it there and it will survive upgrading.

Share this post


Link to post
Share on other sites

Would you be willing to experiment using my project?

The project makes a change to the content.search.php (Advanced Search) template, and uses two code snippets. And possibly a minor change to the Category class file if necessary enhancements didn't make it into CC612.

Share this post


Link to post
Share on other sites
2 hours ago, Dirty Butter said:

I just used upc as an example as it was first in the list in admin. We don't have to provide a upc code, because everything we sell is used. But don't you provide UPC codes?

Don't make the change to Team in definitions.xml. Your change will be lost on upgrade. Find the Language section in admin, click on your flag, and look in Category. You can change it there and it will survive upgrading.

Ahh...good point. I'll edit there as well.  I actually don't use UPC codes because baseball cards aren't sold individually at the retail store level.

30 minutes ago, bsmither said:

Would you be willing to experiment using my project?

The project makes a change to the content.search.php (Advanced Search) template, and uses two code snippets. And possibly a minor change to the Category class file if necessary enhancements didn't make it into CC612.

Of course I would, Brian! Just let me know!

Share this post


Link to post
Share on other sites

The edits you made to modify 'UPC code' in your skin is basically all you have to do to add a new field as well, e.g. instead of modifying one of the lines, add a new one:

// Existing line:
<div><label for="upc_code">{$LANG.catalogue.product_upc}</label><span><input name="upc" id="upc" class="textbox" type="text" value="{$PRODUCT.upc}" maxlength="20"></span></div>
// Add new field:
<div><label for="team">{$LANG.catalogue.product_team}</label><span><input name="team" id="team" class="textbox" type="text" value="{$PRODUCT.team}" maxlength="50"></span></div>
// remaining fields

// In your store front skin, add the new field:
<div id="product_description">
	{$PRODUCT.description}
	<p><strong>{$LANG.catalogue.product_code}</strong>: {$PRODUCT.product_code}</p>
	<p><strong>{$LANG.catalogue.product_team}</strong>: {$PRODUCT.team}</p>
</div>

// One extra change is needed to the database (not sure on max length for your team names - I chose 50 just to be fairly safe):
ALTER TABLE `CubeCart_inventory` ADD COLUMN `team` VARCHAR(50) NULL DEFAULT NULL AFTER `mpn`;

Speaking of which, there is a `brand` column that could suit your needs and appears to be currently unused (with no way to edit it) - you could simply add that into the editable fields for the product:

// Existing line:
<div><label for="upc_code">{$LANG.catalogue.product_upc}</label><span><input name="upc" id="upc" class="textbox" type="text" value="{$PRODUCT.upc}" maxlength="20"></span></div>
// Add new field:
<div><label for="brand">{$LANG.catalogue.product_brand}</label><span><input name="brand" id="brand" class="textbox" type="text" value="{$PRODUCT.brand}" maxlength="20"></span></div>
// remaining fields

In any of the above cases, you would need to swap `upc` for either `team` or `brand` in the search code bhsmither is going to provide for you.

And just to reiterate - none of these solutions solves the problem you mentioned earlier, namely that you need the ability to have more than one team associated with each product. If that's still a requirement, I suggest you create a table to hold product_id:team_id relationships - that will, however, make searching that much more complex.

Share this post


Link to post
Share on other sites

I was making an assumption that multiple team names could be input on each of the other Codes lines, but only show if there were more than one team on that particular card. Of course I have no idea how complicated that would make Search!

Share this post


Link to post
Share on other sites
24 minutes ago, Dirty Butter said:

I was making an assumption that multiple team names could be input on each of the other Codes lines, but only show if there were more than one team on that particular card. Of course I have no idea how complicated that would make Search!

That is certainly a possibility, but it isn't very scalable - you have to add a new field or change an existing one as well as re-modify the search query each time you need an extra team.

So for example let's say we think 2 possible team associations per product is fine and we do all the work to add that in, but then down the line we find out we  have a product that needs 3; now we have to go back and do a bunch of work again to make that possible, whereas it could be done now in a way that allows any number of associations.

Whether that is worth doing, however, depends on whether that situation will ever actually come up, as it is certainly easier to just add 2 fields and call it good.

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

×