AJAX Attribute Manager - v3.0.0. CE

Instructions for Installing on osCommerce CE Phoenix and 2.3.4.(1) BS<

The idea of this contribution is to make the administration of product options, option values and attributes much quicker and easier.

It uses a technology known as AJAX (Asynchronous JavaScript And XML). This enables us to do is make page sub-reqests without refreshing a page.
In this case, it enables us to make a attribute manager that sits on the product addition page. From which, you can do everything (ish - see notes) that the product attributes page does but in a much more convenient and tidy way.






System Requirements

All the normal osCommerce requirements, plus ...

Features


Optional Features


Future Additions (to-do list)


Notes


Support


Contact Details

 

 

Install Instructions

Note: if you are upgrading from a previous version you must OVERWRITE all files in the attributeManager directory. The best way is to delete the whole folder then add the new one.

1) Copy the attribute Manager Directory and all of it's contents into your admin directory.
(Your file structure should look like this /admin/attributeManager/)

2) Open admin/categories.php

Find (Around line 253 on a fresh 2.3.4BS)
          tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");
}
Below add
/** AJAX Attribute Manager  **/ 
require_once('attributeManager/includes/attributeManagerUpdateAtomic.inc.php');
/** AJAX Attribute Manager end **/

2.1) Again in admin/categories.php

Find (around line 610 on a fresh 2.3.4BS)
          <tr bgcolor="#ebebff">
<td class="main"><?php echo TEXT_PRODUCTS_PRICE_GROSS; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_price_gross', $pInfo->products_price, 'onkeyup="updateNet()"'); ?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>

Below add
<!-- AJAX Attribute Manager  -->
<tr>
<td colspan="2"><?php require( 'attributeManager/includes/attributeManagerPlaceHolder.inc.php' )?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<!-- AJAX Attribute Manager end -->

3) Open admin/includes/templates_top.php

Find (Around line 40 on a fresh 2.3.4BS)
</head>
BEFORE add
<!-- AJAX Attribute Manager  -->
<?php
if ((basename($_SERVER["SCRIPT_NAME"]) == 'categories.php')) {
require('attributeManager/includes/attributeManagerHeader.inc.php');
}
?>
<!-- AJAX Attribute Manager end -->

3.1) Again in admin/includes/templates_top.php

Find (Around line 41 on a fresh 2.3.4BS)
<body>
Replace With
<body onload="goOnLoad();">

Finished !

---> Go and add or edit a product and you should see the new attribute manager below the price.

 

 

Additonal Notes for other contribution compatability

(Only needed if you have any of the following contributions installed)

 

 

- Instructions for Sort Order Addon

1) If you haven't installed the attribute sort order contrib then you should install that one first: http://addons.oscommerce.com/info/1822

2) Open admin/attributeManager/classes/attributeManagerConfig.class.php
Find (Around line 60)
        /**
         * Options Sort Order
         */
         $this->add('AM_USE_SORT_ORDER' , false);

Change from false to true if you want to use the sort order functionality
        /**
         * Options Sort Order
         */
         $this->add('AM_USE_SORT_ORDER' , true);


Find (Around line 65)
		$this->add('AM_FIELD_OPTION_SORT_ORDER','products_options_sort_order'); // Sort column on Products_options table
$this->add('AM_FIELD_OPTION_VALUE_SORT_ORDER','products_options_sort_order'); // Sort column on product_attributes table
Change the column name to whatever your sort column is called on each of your database tables  
 
now add the fields you just changed in attributeMangagerConfig.class.php (products_options_sort_order)...

If you are using CE Phoenix or CE Frozen or another EDGE version with modularized product_info.php, upload and replace:
catalog (compare files for [your store version])/includes/modules/content/product_info/cm_pi_options_attributes.php

Otherwise change catalog/product_info.php:
SQL Query in product_info.php
      $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.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
      while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
        $products_options_array = array();
        $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.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
To:
      $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.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_sort_order");
      while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
        $products_options_array = array();
        $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.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' order by pa.products_options_sort_order");
If you are using 2.3.4.1 CE Frozen with modular product_info.php: SQL Query in includes/modules/content/product_info/cm_pi_products_attributes.php
      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from products_options popt, products_attributes patrib where patrib.products_id='" . (int)$_GET['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
To:
// attributes sort order added
      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from products_options popt, products_attributes patrib where patrib.products_id='" . (int)$_GET['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_sort_order, popt.products_options_name");
If you are using 2.3.4.1 CE Frozen with modular product_info.php: SQL Query in includes/modules/content/product_info/cm_pi_products_attributes.php
          $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 products_attributes pa, products_options_values pov where pa.products_id = '" . (int)$_GET['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
To:
// attributes sort order added
          $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 products_attributes pa, products_options_values pov where pa.products_id = '" . (int)$_GET['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' order by pa.products_options_sort_order");

 

 

- Instructions for QT Pro

1) If you haven't installed the QT Pro contrib then you should install that one first: http://addons.oscommerce.com/info/888

2) Open admin/attributeManager/classes/attributeManagerConfig.class.php
Find (Around line 72)
        /**
         * QT Pro plugin
         */
        $this->add('AM_USE_QT_PRO', false);
        $this->add('AM_DELETE_ZERO_STOCK', false); // if true, deletes options combinations with zero quantity from stock
Change from false to true if you want to use this functionality
        /**
         * QT Pro plugin
         */
        $this->add('AM_USE_QT_PRO', true);
        $this->add('AM_DELETE_ZERO_STOCK', false); // if true, deletes options combinations with zero quantity from stock

 

 

- Instructions for More Product Weight plugin

1) If you haven't installed the More Product Weight plugin contrib then you should install that one first: http://addons.oscommerce.com/info/2706

2) Open admin/attributeManager/classes/attributeManagerConfig.class.php
Find (Around line 78)
        /**
         * Use More Product Weight plugin? (http://addons.oscommerce.com/info/2706) (added by RusNN)
         */
        $this->add('AM_USE_MPW', false);
Change from false to true if you want to use this functionality
        /**
         * Use More Product Weight plugin? (http://addons.oscommerce.com/info/2706) (added by RusNN)
         */
        $this->add('AM_USE_MPW', true);

 

 

- Instructions for Options Images BS plugin (version 1.5 or higher required)

1) If you haven't installed the Options Images BS plugin contrib then you should install that one first: https://apps.oscommerce.com/ijmp8&options-images-bs

2) Open admin/attributeManager/classes/attributeManagerConfig.class.php

NOTE:
- Options images are displayed both, Products Options Images and Options Value Images
- Only Products Options Images can be added, edited or deleted in Ajax Attribute Manager
- No image file uploads, images need to be uploaded apart (via ftp or the core attributes page) and image filenames need to be introduced like for download files.


Find (Around line 89)
        /**
         * Use Options Images plugin? (https://apps.oscommerce.com/ijmp8&options-images-bs) (added by @raiwa)
         */
        $this->add('AM_USE_IMAGE', false);
        
Change from false to true if you want to use this functionality
        /**
         * Use More Product Weight plugin? (http://addons.oscommerce.com/info/2706) (added by RusNN)
         */
        $this->add('AM_USE_IMAGE', true);

 

 

- Instructions to add Extra Fields

There is loads of contribution available for the attribute functionality. Each add different columns to the database and have different way of managing their update. If you want to add extra field to the Ajax Attribute Manager, to handle database values contained in the product_attributes tables, it is quiet easy to do. File to be changed are as follow:
attributeManager.php for the display of the new field and the insert and update action trigger (around line 196 & 271)
attributeManager.class.php (around line 457)
attributeManagerAtomic.class.php (around line 70, 150, 170)
attributeManagerInstant.class.php (around line 70, 133, 173)
attributeManagerUpdateAtomic.inc.php (around line 30)
attributeManager.js (around line 85, 106, 110)
Search for the "price" string and simply mimic the mechanism used for this field, you can also check the way sort order was added