Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Attribute Groups


deuce23

Recommended Posts

Posted

The site i'm putting together is going to have 90% of the products with the same attributes. I have seen other posts asking for attribute groups and after planning out my products and attributes, I can see where it would be benificial for certain sites.

 

I have made some minor changes to product_info.php that allows for the implementation of attribute groups. I needed to add an extra column to the products_attributes and products table for this to work. It also allows for the assignment of additional attributes to a single item along with the group. At lease in my case, this will reduce the size of my attributes table down to a dozen or so entries as opposed to 1000 or more. There are some other changes that need to be made to the admin files to facilitate the data entry process.

 

Below is the section of code I changed which starts at line 103 from snapshot 20030523. I added attributes_group_id to products_attributes and attribute_id to products.

 

I have some VB experience but up until a week ago when I downloaded OSC, I have never seen PHP so, I apologize now for any coding/formating mistakes.

 

<?php

$attributes_id_query = tep_db_query("select pp.attribute_ID from " . TABLE_PRODUCTS . " pp where products_id='" . (int)$HTTP_GET_VARS['products_id'] . "'");

$attributes_id = tep_db_free_result($attributes_id_query);

   if ($attributes_id <> 0) {

 echo '<b>' . TEXT_PRODUCT_OPTIONS . ' </b><br>' .

          '<table border="0" cellpadding="0" cellspacing"0">';

     $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where (patrib.attributes_group_id='" . $attributes_id . "' or patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "') and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'");

     while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {

       $selected = 0;

       $products_options_array = array();

       echo '<tr><td class="main">' . $products_options_name['products_options_name'] . ':</td><td>' . "n";

       $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where (pa.attributes_group_id='" . $attributes_id . "' or pa.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "') and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'");

       while ($products_options = tep_db_fetch_array($products_options_query)) {

         $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);

         if ($products_options['options_values_price'] != '0') {

           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

         }

       }

       echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']]);

       echo '</td></tr>';

     }

     echo '</table>';

   }



?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...