Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Both contributions seperately work just fine, but when merged together I keep getting the following error: :crazy:

 

---------------------------------------------------------------------

1136 - Column count doesn't match value count at row 1

 

insert into products_attributes values ('', '57', '4', '25', '', '')

 

[TEP STOP]

---------------------------------------------------------------------

 

Anyone had any luck with combining:

- Quantitiy Controller v5.1;

- Alternative attributehandling(5).

 

... it's getting late and I can't see straight :rockedover:

Posted

You need to have the right number of fields for that insert statement.

 

Off the top of my head I would say you are short a field.

Posted

Thanks ... guess it's the extra field from the quantity controller? (since the product_attributes_table is altered)

 

Will repost ... whether I have any luck :D or not :cry:

Posted

As Linda mentioned there was a field missing, thanks again :wink: For those interested, below are the adjustments that should be made. Check the original contributions for further details:

- Quantity Controller v5.1

- Alternative Attribute Handling(5)

 

 

Since the Quantity Controller adds an extra field to the products_attributes table, this should be incorporated too ... duh :oops:

 

          // Update Product Attributes

         // Add Sort Order field

         $rows = 0;

         $options_query = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $languages_id . "' order by products_options_name");

         while ($options = tep_db_fetch_array($options_query)) {

           $values_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " p2p where pov.products_options_values_id = p2p.products_options_values_id and p2p.products_options_id = '" . $options['products_options_id'] . "' and pov.language_id = '" . $languages_id . "'");

           while ($values = tep_db_fetch_array($values_query)) {

             $rows ++;

             $attributes_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix, products_options_sort_order from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $products_id . "' and options_id = '" . $options['products_options_id'] . "' and options_values_id = '" . $values['products_options_values_id'] . "'");

             if (tep_db_num_rows($attributes_query) > 0) {

               $attributes = tep_db_fetch_array($attributes_query);

               if ($HTTP_POST_VARS['option'][$rows]) {

                 if ( ($HTTP_POST_VARS['prefix'][$rows] <> $attributes['price_prefix']) || ($HTTP_POST_VARS['price'][$rows] <> $attributes['options_values_price']) || ($HTTP_POST_VARS['sort_order'][$rows] <> $attributes['products_options_sort_order']) ) {

                   tep_db_query("update " . TABLE_PRODUCTS_ATTRIBUTES . " set options_values_price = '" . $HTTP_POST_VARS['price'][$rows] . "', price_prefix = '" . $HTTP_POST_VARS['prefix'][$rows] . "', products_options_sort_order = '" . $HTTP_POST_VARS['sort_order'][$rows] . "' where products_attributes_id = '" . $attributes['products_attributes_id'] . "'");

                 }

               } else {

                 tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_attributes_id = '" . $attributes['products_attributes_id'] . "'");

               }

             } elseif ($HTTP_POST_VARS['option'][$rows]) {

               tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . $products_id . "', '" . $options['products_options_id'] . "', '" . $values['products_options_values_id'] . "', '" . $HTTP_POST_VARS['price'][$rows] . "', '" . $HTTP_POST_VARS['prefix'][$rows] . "', '" . $HTTP_POST_VARS['sort_order'][$rows] . "')");

             }

           }

         }

 

Finally, add corresponding textfield for input

 

<?php

   $rows = 0;

   $options_query = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $languages_id . "' order by products_options_name");

   while ($options = tep_db_fetch_array($options_query)) {

     $values_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " p2p where pov.products_options_values_id = p2p.products_options_values_id and p2p.products_options_id = '" . $options['products_options_id'] . "' and pov.language_id = '" . $languages_id . "'");

     $header = false;

     while ($values = tep_db_fetch_array($values_query)) {

       $rows ++;

       if (!$header) {

         $header = true;

?>

           <td><table border="0" cellpadding="2" cellspacing="0">

             <tr class="dataTableHeadingRow">

               <td class="dataTableHeadingContent" colspan="4"><?php echo $options['products_options_name']; ?></td>

             </tr>



// added extra row which shows what the textfields stand for



             <tr bgcolor="#000000">

               <td class="dataTableHeadingContent">(un)check</td>

               <td class="dataTableHeadingContent">prefix</td>

               <td class="dataTableHeadingContent">price</td>

               <td class="dataTableHeadingContent">rank</td>

             </tr>

<?php

        }

        $attributes = array();

        if (sizeof($HTTP_POST_VARS) > 0) {

          if ($HTTP_POST_VARS['option'][$rows]) {

           $attributes = array('products_attributes_id' => $HTTP_POST_VARS['option'][$rows],

                               'options_values_price' => $HTTP_POST_VARS['price'][$rows],

                               'price_prefix' => $HTTP_POST_VARS['prefix'][$rows],

                               'products_options_sort_order' => $HTTP_POST_VARS['sort_order'][$rows]);

         }

       } else {

         $attributes_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix, products_options_sort_order from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $pInfo->products_id . "' and options_id = '" . $options['products_options_id'] . "' and options_values_id = '" . $values['products_options_values_id'] . "'");

         if (tep_db_num_rows($attributes_query) > 0) {

           $attributes = tep_db_fetch_array($attributes_query);

         }

       }

?>

             <tr class="dataTableRow">

               <td class="dataTableContent"><?php echo tep_draw_checkbox_field('option[' . $rows . ']', $attributes['products_attributes_id'], $attributes['products_attributes_id']) . ' ' . $values['products_options_values_name']; ?> </td>

               <td class="dataTableContent"><?php echo tep_draw_input_field('prefix[' . $rows . ']', $attributes['price_prefix'], 'size="2"'); ?></td>

               <td class="dataTableContent"><?php echo tep_draw_input_field('price[' . $rows . ']', $attributes['options_values_price'], 'size="7"'); ?></td>

               <td class="dataTableContent"><?php echo tep_draw_input_field('sort_order[' . $rows . ']', $attributes['products_price_sort_order'], 'size="2"'); ?></td>

             </tr>

<?php

     }

     if ($header) {

?>

           </table></td>

<?php

     }

   }

?>

 

Good luck! :D

  • 5 weeks later...
Posted

Thanks belladonna. I followed your steps and it works like a breeze. Nice touch on the extra row :D

 

Chow

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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...