Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Development] Products Specifications


kymation

Recommended Posts

Look up a couple of posts.

 

The Product Filter page was a way of showing the results of filters without extensive modifications to the index.php that shows the normal category listings. It could be done, but it would be complicated. Your customers shouldn't notice anyway.

 

Regards

Jim

 

 

Jim,

 

Thanks for your comments. Did you get chance to look under the budget safes section to see why the filter was not working as it should?

 

 

Regards

 

James

Link to comment
Share on other sites

I'm not sure about the actual values, but I just fixed an issue I had with ampersands and ö characters by adding a urlencode around the tep_output_string call in the links section and making the tep_clean_recursive less restrictive ...

 

perhaps something happening along those lines ?

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

PS I just generated an xls with adapted easypopulate 2.72 attribute code for specs, it is at the moment just outputting what is in the system, but at least it is an easy check to spot inconsistencies.

 

for the upload logic, I'm a bit struggling to see if I can figure out an insert or an update of existing values, and how I would go about removing particular entries, though deleting entries might not be a big issue at all.

I'm not sure yet, I need to think this through and sleep over it :D

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Hi

 

I have installed the product specifications addon and it works fine, however it is very long placing the neccesary products with the correct specification group as you have to go into each product within the catalog section and add the product to the spec group, and having 1300 products this could take me a long time. My question is: If i installed the addon 'add extra field to easypopulate and created a specification column in easypopulate could it be mapped to the specifications and then just be typed into the neccesary cell. Then if all the spec groups were already setup i could just type that group into the right cell in the spreadsheet in the spec colum and it would add the neccesary product. I could put all the products in the correct pre-setup specification groups in the spreadsheet.

 

Will this work at all

 

Regards

 

Peter

Link to comment
Share on other sites

I'm a bit confused by this. Specification Groups can be linked to Categories, not Products. You can link a Specification Group to all Categories with a single click. This will include all of your products by default.

 

Products Specifications automatically supports any Addon that adds a column to the products or products_description table in the database. The new column can then be selected as an existing column and linked to a Specification. Addons that use a separate table, such as the Products Extra Fields Addon, are not supported. Changes to Easy Populate may be needed to accommodate the added column.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Hi

 

I have installed the product specifications addon and it works fine, however it is very long placing the neccesary products with the correct specification group as you have to go into each product within the catalog section and add the product to the spec group, and having 1300 products this could take me a long time. My question is: If i installed the addon 'add extra field to easypopulate and created a specification column in easypopulate could it be mapped to the specifications and then just be typed into the neccesary cell. Then if all the spec groups were already setup i could just type that group into the right cell in the spreadsheet in the spec colum and it would add the neccesary product. I could put all the products in the correct pre-setup specification groups in the spreadsheet.

 

Will this work at all

 

Regards

 

Peter

I guess you haven't read even the last post in this thread heuh ? :o

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

after another evening of tweaking EasyPopulate I now have a dirty but functional version that I'm testing out to download products and specifications, and to update the specifications (currently updating the language specific specification_value_descriptions, and products_specifications tables).

 

I realize the code is not that great, and my version contains some changes that might not be compatible with a standard install, so if anyone is interested in this code to help trim the code and debug it, make it more foolproof please send me an email.

If you are not able to figure out why sql fails (because of fields I have, and you don't, then this piece of code is not yet ready for you .... B)

 

Ciao

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

FYI, On my system there was an incompatibility between admin/products_specifications.php and the mindsparx admin where the url parameter $_GET['value'] stored in $value was overwritten.

I've changed all references to $_GET['svalue'] and stored it in the $svalue variable to avoid any conflict.

 

On the easypopulate front I can now just extract the specs in use for a selected category, and also show the text fields. Updating of free text fields is not yet working ...

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

  • 2 weeks later...

Not sure if this has been reported before, but when I have filters with checkboxes, when checking 2 values (not the show all options if you have that), it gives a Sql error as the table alias eg f10 is used twice.

I haven't delved into this bit of code, not sure if it can be fixed easily with extending the alias logic to make it unique or if some more logic is needed to allow for multiple filter values without requiring another table alias.

 

you can find the issue on my shop under small appliances / coffe & tea / espresso

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

I see

f70 =Yes&f70 =No

as the duplicates. First, there is a space in the string just after each variable, and that should never happen with this code. Is the forum software adding that, or is it really there?

 

Secondly, the code should be generating an array, so this should look something like:

f70[1]=Yes&f70[2]=No

Check your catalog/includes/functions/products_specifications.php -- does Line 678 look like this:

              $box_text .= tep_draw_checkbox_field ($filter_name . '[' . $checkbox_id . ']', $filter['id'], $checked) . ' ' . $filter['text'];

That code adds the array key to each of the checkboxes.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

  • 5 weeks later...

I see

f70 =Yes&f70 =No

as the duplicates. First, there is a space in the string just after each variable, and that should never happen with this code. Is the forum software adding that, or is it really there?

 

Secondly, the code should be generating an array, so this should look something like:

f70[1]=Yes&f70[2]=No

Check your catalog/includes/functions/products_specifications.php -- does Line 678 look like this:

              $box_text .= tep_draw_checkbox_field ($filter_name . '[' . $checkbox_id . ']', $filter['id'], $checked) . ' ' . $filter['text'];

That code adds the array key to each of the checkboxes.

 

Regards

Jim

 

this line looked the same except for the space which I have as a non-breaking space html entity

 

However, I found that by making this change at around line 419, it resolved the double alias issue

I marked my changes with BOF CB Mod and EOF CB Mod comments

 

     switch ($filter_class) {
       case 'exact' :
         $filter_array = array_map ('tep_set_filter_case', $filter_array);
         foreach ($filter_array as $filter) {
           if (isset ($filter) && $filter != '0' && $filter != '') {
             if (strlen($products_column_name) > 1) { // Use an existing column
               $sql_array['where'] .= " AND " . $products_column_name . " <=> " . $filter . " ";
             } else {
			//BOF CB Mod
  			$i = 0;
			while (strpos($sql_array['from'], 'ps'.$specifications_id) > 0) {
				$specifications_id = $specifications_id . '_'. $i;
				$i++;
				//echo $specifications_id;
			}
			//EOF CB Mod

               $sql_array['from'] .= " INNER JOIN " . TABLE_PRODUCTS_SPECIFICATIONS . " ps" . $specifications_id . " ON p.products_id = ps" . $specifications_id . ".products_id ";
               $sql_array['where'] .= " AND ps" . $specifications_id . ".specification <=> " . $filter . "
                             AND ps" . $specifications_id . ".specifications_id = '" . $specifications_id . "'
                             AND ps" . $specifications_id . ".language_id = '" . (int) $languages_id . "'
                             ";
             } // if (strlen ($products_column_name ... else ...
           } // if (isset ($filter
         } // foreach ($filter_array
         break;

       case 'multiple' :
         $filter_array = array_map ('tep_set_filter_case', $filter_array);
         if (strlen($products_column_name) > 1) {
           $sql_array['where'] .= " and " . $products_column_name . " in (";
           $first = true;
           foreach ($filter_array as $filter) {
             if ($first == true) {
               $first = false;
               $sql_array['where'] .= " " . $filter . " ";
             } else {
               $sql_array['where'] .= ", " . $filter . " ";
             }
           }
           $sql_array['where'] .= ") ";

         } else {
		//BOF CB Mod
		$i = 0;
		while (strpos($sql_array['from'], 'ps'.$specifications_id) > 0) {
		  $specifications_id = $specifications_id .'_'. $i;
		  $i++;
		  //echo $specifications_id;
		}
		//EOF CB Mod
           $sql_array['from'] .= " INNER JOIN " . TABLE_PRODUCTS_SPECIFICATIONS . " ps" . $specifications_id . " ON p.products_id = ps" . $specifications_id . ".products_id ";

 

Hope this helps someone ...

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

I just tried the copy functionality for specification groups, and noticed that the data in specification_description table is not copied, and as a result, no specifications show, but it does report on the filter and values etc being defined.

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Thanks for the code. I need to revisit this function when I get time. If that ever happens.

 

I have a bug report on the Copy function. It's pretty much useless as it is. I really need to fix that as well.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Jim,

I'm trying to reduce the number of database queries, but I'm having trouble seeing where the iteration is coming from

 

An example, when I've selected a category below query is executed for each manufacturer to retrieve the product count

select count(p.products_id) as count 
 from (products p) join (products_to_categories p2c) on (p.products_id = p2c.products_id) 
 left join (specials s) on (p.products_id = s.products_id) 
where p.products_status = '1' 
  and p2c.categories_id in (90,230,229,391,233,235,232,234,231)
  and p.manufacturers_id <=> 123

 

I'd like to change it so that the following sql returns the manufacturers with their product count

select manufacturers_id, count(p.products_id) as count 
 from (products p) join (products_to_categories p2c) on (p.products_id = p2c.products_id) 
 left join (specials s) on (p.products_id = s.products_id) 
where p.products_status = '1' 
  and p2c.categories_id in (90,230,229,391,233,235,232,234,231)
   group by p.manufacturers_id

 

I'm not 100% sure if this would work for specifications too, but I sure would like to try as I think it would make the system much faster.

 

Any hints to put me on the right track ?

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Combining SQL is not always the best way to go. Given that this one has that group by condition, I think that trying to retrieve the manufacturers_id at the same time will make it slower. That's only a guess, so you should probably try it to be certain.

 

I believe that the code you want is in the getFilterCount() method of the Specifications class, in catalog/includes/classes/specifications.php.

 

Regards

Jim

Edited by kymation

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

I haven't seen this topic come up anywhere else, but please point me in the right direction if it has.

 

I'm using products specifications on a customer site that sells electronic parts to engineers, so the comparison table page is very important to them. The problem I have is that they really need to change the default sort of the tables in the comparison page to sort by one of their custom specifications (rated power). If the table could be changed to allow user sorting by clicking the column header that would be ideal, but just changing the default sort would be enough. Here's an example:

 

http://powersupplyemporium.com/index.php?cPath=46_109

 

Thanks in advance for this great oscommerce mod and any help you can give me...

Link to comment
Share on other sites

The Comparison table is not set up to be sorted by an arbitrary Specification. I'm certain that can be done, but it won't be simple. You could sort the products by an arbitrary field in the Products table by adding that field to the $columns_query_raw. Something like the Sort Order Addon does to stock osCommerce.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

maybe it is an option to look for an ajax based html table sorting solution see http://datatables.net for loads of inspiration

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

hey Guys,

 

this is just a change in the set out of the spec on product_info.php

 

add to stylesheet.css

.specification{
font-family: Tahoma, Verdana, Arial, sans-serif;
 color: #000000;
 font-size: 13px;
}
.specification_bold{
font-family: Tahoma, Verdana, Arial, sans-serif;
 color: #000000;
 font-size: 13px;
 font-weight: bold;
}

 

and I changed includes-modules-product_specification.php

$specification_text = '<ul class=specification_box>' . "\n";

   while ($specifications = tep_db_fetch_array ($specifications_query) ) {
     if ($specifications['specification'] != '') {
       $specification_text .= '<li>';

       if (SPECIFICATIONS_SHOW_NAME_PRODUCTS == 'True') {
         $specification_text .= $specifications['specification_name'] . ': ';
       }

       $specification_text .= $specifications['specification_prefix'] . ' ';

       if ($specifications['display'] == 'image' || $specifications['display'] == 'multiimage' || $specifications['enter'] == 'image' || $specifications['enter'] == 'multiimage') { 
         tep_image (DIR_WS_IMAGES . $specifications['specification'], $specifications['specification_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
       } else {
         $specification_text .= $specifications['specification'] . ' ';
       }

       $specification_text .= $specifications['specification_suffix'];
       $specification_text .= '</li>' . "\n";
     } // if ($specifications['specification']
   } // while ($specifications
   $specification_text .= '</ul>' . "\n";

 

to

 

$specification_text = '<ul>' . "\n";

   while ($specifications = tep_db_fetch_array ($specifications_query) ) {
     if ($specifications['specification'] != '') {
       $specification_text .= '<div id="speci"><table colspan="2" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><span class="pageHeadingSM">';

       if (SPECIFICATIONS_SHOW_NAME_PRODUCTS == 'True') {
           $specification_text .= '<td width="21%" class="specification_bold"><li>';
           $specification_text .= $specifications['specification_name'] . ': ';
		$specification_text .= '</li></td>';
       }
	$specification_text .= '<td width="79%" class="specification">';
       $specification_text .= $specifications['specification_prefix'] . ' ';

       if ($specifications['display'] == 'image' || $specifications['display'] == 'multiimage' || $specifications['enter'] == 'image' || $specifications['enter'] == 'multiimage') { 
         tep_image (DIR_WS_IMAGES . $specifications['specification'], $specifications['specification_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
       } else {
         $specification_text .= $specifications['specification'] . ' ';
       }

       $specification_text .= $specifications['specification_suffix'];
       $specification_text .= '</td>';
       $specification_text .= '' . "\n";
     } // if ($specifications['specification']
   } // while ($specifications
   $specification_text .= '</span></tr></table></div>';
   $specification_text .= '</ul>' . "\n";

 

 

Thats it

 

hope this helps someone

 

Al

Link to comment
Share on other sites

amendment for above change to bellow

$specification_text = '<ul><div id="speci"><table colspan="2" border="0" cellpadding="0" cellspacing="0" width="100%">' . "\n";

   while ($specifications = tep_db_fetch_array ($specifications_query) ) {
     if ($specifications['specification'] != '') {
       $specification_text .= '';

       if (SPECIFICATIONS_SHOW_NAME_PRODUCTS == 'True') {
           $specification_text .= '<tr><td width="21%" class="specification_bold"><li>';
           $specification_text .= $specifications['specification_name'] . ': ';
		$specification_text .= '</li></td>';
       }
	$specification_text .= '<td width="79%" class="specification">';
       $specification_text .= $specifications['specification_prefix'] . ' ';

       if ($specifications['display'] == 'image' || $specifications['display'] == 'multiimage' || $specifications['enter'] == 'image' || $specifications['enter'] == 'multiimage') { 
         tep_image (DIR_WS_IMAGES . $specifications['specification'], $specifications['specification_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
       } else {
         $specification_text .= $specifications['specification'] . ' ';
       }

       $specification_text .= $specifications['specification_suffix'];
       $specification_text .= '</td></tr>';
       $specification_text .= '' . "\n";
     } // if ($specifications['specification']
   } // while ($specifications
   $specification_text .= '</table></div>';
   $specification_text .= '</ul>' . "\n";

 

 

as a side point I was looking into striping each table row stated in the posts above and knew I had code for that somewhere

create a file called zebra.js and paste

a normal call would be as bellow but it needs to be a Div call or something because we already have a js call for the tabs

I cant get this to work if some could shed some light it would be great!!

<script type="text/javascript" src="js/zebra.js"></script> 
<script type="text/javascript">
$(document).ready(function() {
stripe("#SPEC");
});
</script>

 

  // this function is needed to work around 
 // a bug in IE related to element attributes
 function hasClass(obj) {
    var result = false;
    if (obj.getAttributeNode("class") != null) {
        result = obj.getAttributeNode("class").value;
    }
    return result;
 }   

function stripe(id) {

   // the flag we'll use to keep track of 
   // whether the current row is odd or even
   var even = false;

   // if arguments are provided to specify the colours
   // of the even & odd rows, then use the them;
   // otherwise use the following defaults:
   var evenColor = arguments[1] ? arguments[1] : "#ffff99";
   var oddColor = arguments[2] ? arguments[2] : "";

   // obtain a reference to the desired table
   // if no such table exists, abort
   var table = document.getElementById(id);
   if (! table) { return; }

   // by definition, tables can have more than one tbody
   // element, so we'll have to get the list of child
   // <tbody>s 
   var tbodies = table.getElementsByTagName("tbody");

   // and iterate through them...
   for (var h = 0; h < tbodies.length; h++) {

    // find all the <tr> elements... 
     var trs = tbodies[h].getElementsByTagName("li");

     // ... and iterate through them
     for (var i = 0; i < trs.length; i++) {

       // avoid rows that have a class attribute
       // or backgroundColor style
      // if (! hasClass(trs[i]) &&
       //    ! trs[i].style.backgroundColor) {

         // get all the cells in this row...
         var tds = trs[i].getElementsByTagName("td");

         // and iterate through them...
         for (var j = 0; j < tds.length; j++) {

           var mytd = tds[j];

           // avoid cells that have a class attribute
           // or backgroundColor style
          // if (! hasClass(mytd) &&
           //    ! mytd.style.backgroundColor) {

             mytd.style.backgroundColor =
               even ? evenColor : oddColor;

         //  }
         }
       }
       // flip from odd to even, or vice-versa
       even =  ! even;
     }
   }
// }

 

 

Al

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...