Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

QTPro Attribute Model Number Contribution


darrenultra

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'] . ")");

}

 

 

}

}

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