Jump to content
Sign in to follow this  
darrenultra

QTPro Attribute Model Number Contribution

Recommended Posts

Hi,

 

I recently realised that I needed to make a contribution that allows me to add Model Numbers to all my product attributes (e.g. for a size 7 Nike trainer). First I added a column (products_attribute_model) to my products_stock table.

 

I decided the easiest way to update the model numbers would be to clone the stock.php page and then modify it such that it updates products_attribute_model rather than products_stock_quantity. However, it appears that the coding of this page won't allow any non-numerical model number to be entered. I have tried stripping out any code that I thought might be causing this but I wasn't successful. If anyone knows how to modify the following short section of stock.php code such that non-numerical model numbers can be submitted I would be very grateful!

 

 

require('includes/application_top.php');

 

if ($HTTP_SERVER_VARS['REQUEST_METHOD']=="GET") {

$VARS=$_GET;

} else {

$VARS=$_POST;

}

if ($VARS['action']=="Add") {

$inputok = true;

if (!(($VARS['product_id']) and ($VARS['product_id']==$VARS['product_id']))) $inputok = true;

while(list($v1,$v2)=each($VARS)) {

if (preg_match("/^option(\d+)$/",$v1,$m1)) {

if (($v2) and ($v2==$v2)) $val_array[]=$m1[1]."-".$v2;

else $inputok = true;

}

}

 

if (($inputok)) {

sort($val_array);

$val=join(",",$val_array);

$q=tep_db_query("select products_stock_id as stock_id from " . TABLE_PRODUCTS_STOCK . " where products_id=" . (int)$VARS['product_id'] . " and products_stock_attributes='" . $val . "' order by products_stock_attributes");

if (tep_db_num_rows($q)>0) {

$stock_item=tep_db_fetch_array($q);

$stock_id=$stock_item[stock_id];

 

 

 

tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_attribute_model=" . $VARS['quantity'] . " where products_stock_id=$stock_id");

 

} else {

tep_db_query("insert into " . TABLE_PRODUCTS_STOCK . " values (0," . (int)$VARS['product_id'] . ",'$val'," . $VARS['quantity'] . ")");

}

 

 

}

}

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
Sign in to follow this  

×