Jump to content
homewetbar

Quickly Update Product Stock

Recommended Posts

Please post questions regarding the Quickly Update Product Stock contribution in this forum instead of on the contribution page.

 

Contribution:

http://www.oscommerce.com/community/contributions,558


Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Share this post


Link to post
Share on other sites

There is a problem with your contribution for sites with many catagories...

 

Since you have them listed going across the screen, in my instance, the screen scrolls about 3 pages to the right.

 

Plus, it was not including ALL my catagories, there were 3 catagories left out.

 

This is the change that I have made in order to fix it AND give it a nice look and feel...

 

I made all my changes between the <!-- body //--> and <!-- body_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
<?php
 if ($menu_dhtml == false ) {     // add for dhtml_menu
	 echo '<td width="' . BOX_WIDTH . '" valign="top">';
	 echo '<table border="0" width="' . BOX_WIDTH . '" cellspacing="1" cellpadding="1" class="columnLeft">';
	 echo '<!-- left_navigation //-->';
	 require(DIR_WS_INCLUDES . 'column_left.php');
	 echo '<!-- left_navigation_eof //-->';
	 echo '</table>';
	 echo '</td>';
 } else {

 }
?>
<!-- body_text //-->
 <td width="100%" valign="top">
 <table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td>
   <table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading">Quick Stock Update<br><?php echo tep_draw_separator('pixel_trans.gif', '100%', '4'); ?></td>
           <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
         </tr>
       </table>
   </td>
     </tr>
     <tr>
       <td>
   <table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td valign="top">
   <table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr class="dataTableHeadingRow">
               <td class="dataTableHeadingContent"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
             </tr>
             <tr>
               <td class="pageHeadingsmaller"><br>Choose the category where you want to change the products within</td>
             </tr>
   </table>
   </td>
         </tr>
   </table>
   </td>
     </tr>
     <tr>
       <td>
   <table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td>
<?php
 if ($HTTP_POST_VARS['stock_update']) {
   //set counter
   $stock = 0;
   $status_a = 0;
   $status_d = 0;

   while (list($key, $items) = each($stock_update)) {
     // update the quantity in stock and image
     $sql = "UPDATE products SET products_quantity = '".$items['stock']."', products_model = '".$items['model']."', products_price = '".$items['price']."', products_weight = '".$items['weight']."' WHERE products_id = $key";
     $update = tep_db_query($sql);
     $stock_i++;

     // we're de-re-activating the selected products
     if ($HTTP_POST_VARS['update_status']) {
       if ($items['stock'] >= 1 ) {
         $dereac = tep_db_query("UPDATE products SET products_status = 1 WHERE products_id = $key");
         $status_a++;
       } else {
         $dereac = tep_db_query("UPDATE products SET products_status = 0 WHERE products_id = $key");
         $status_d++;
       }
     }
   }
 }
?>

           <br><form method="post" action="quick_stockupdate.php">

<?php
// first select all categories that have 0 as parent:
 $sql = tep_db_query("SELECT c.categories_id, cd.categories_name from categories c, categories_description cd WHERE c.parent_id = 0 AND c.categories_id = cd.categories_id AND cd.language_id = 1");

 echo '            <table border="0">';
 echo '              <tr>';
 while ($parents = tep_db_fetch_array($sql)) {
   // check if the parent has products
   $check = tep_db_query("SELECT products_id FROM products_to_categories WHERE categories_id = '" . $parents['categories_id'] . "'");

   $tree = tep_get_category_tree();
   $dropdown= tep_draw_pull_down_menu('cat_id', $tree, '', 'onChange="this.form.submit();"'); //single
   $all_list = '                <form method="post" action="quick_stockupdate.php"><th class="smallText" align="left" valign="top">Categories:<br>' . $dropdown . '</form></th>';
 }
 echo $all_list;
 echo '              </tr>';
 echo '            </table>';
 echo '            </form>';
 echo '            </td>';
 echo '          </tr>';
 echo '        </table>';

 // see if there is a category ID:
 if ($HTTP_POST_VARS['cat_id']) {
   // start the table
   echo '            <br><form method="post" action="quick_stockupdate.php">';
   echo '            <table width="100%" border="0" cellspacing=0 cellpadding=2>';
   $i = 0;

   // get all active prods in that specific category
   $sql2 = tep_db_query("SELECT p.products_model, p.products_id, p. products_quantity, p.products_status, p.products_weight, p.products_price, pd.products_name from products p, products_to_categories ptc, products_description pd where p.products_id = ptc.products_id and p.products_id = pd.products_id and language_id = $languages_id and ptc.categories_id = '" . $HTTP_POST_VARS['cat_id'] . "' order by pd.products_name");

   echo '            <tr class="dataTableHeadingRow">';
   echo '              <td width="35" class="dataTableHeadingContent"> <b>ID#</b></td>';
   echo '              <td class="dataTableHeadingContent"> <b>SKU #</b></td>';
   echo '              <td width="400" class="dataTableHeadingContent">    <b>Name</b></td>';
   echo '              <td class="dataTableHeadingContent">    <b>Weight</b></td>';
   echo '              <td class="dataTableHeadingContent">     <b>Price</b></td>';
   echo '              <td class="dataTableHeadingContent">     <b>Stock</b></td>';
   echo '            </tr>';
   // added changes thowden 10/2004 stock_update becomes a multi-dim array
   while ($results = tep_db_fetch_array($sql2)) {
      $i++;
      echo '            <tr class="dataTableRow">';
  echo '              <td class="dataTableContent"> ' . $results['products_id'] . ' </td>';
      echo '              <td class="dataTableContent"> <input type="text" size="16" name="stock_update[' . $results['products_id'] . '][model]" value="' . $results['products_model'] . '"> </td>';
  echo '              <td class="dataTableContent">   ' . $results['products_name'] . ' </td>';
  echo '              <td class="dataTableContent">   <input type="text" size="6" name="stock_update[' . $results['products_id'] . '][weight]" value="' . $results['products_weight'] . '"> </td>';
  echo '              <td class="dataTableContent">    <input type="text" size="9" name="stock_update[' . $results['products_id'] . '][price]" value="' . $results['products_price'] . '"> </td>';
  echo '              <td class="dataTableContent">    <input type="text" size="4" name="stock_update[' . $results['products_id'] . '][stock]" value="' . $results['products_quantity'] . '">' . (($results['products_status'] == 0) ? '  <font color="ff0000"><b>not active</b></font>' : '  <font color="009933"><b>active</b></font> </td>');
      echo '            </tr>';
      if ($i == $max_cols) {
        $i = 0;
      }
   }
   echo '</table><table border="0" width="100%" cellspacing=2 cellpadding=2><tr>';
   echo '<input type="hidden" name="cat_id" value="' . $HTTP_POST_VARS['cat_id'] . '">';
   echo '</tr><br><td align="center" colspan="10" class="smallText">';
   echo '<input type="checkbox" name="update_status" CHECKED>Check to set status on each individual product based on items in stock<br><i>( one or more in stock will become <font color="009933"><b>active</b></font> / zero in stock will become <font color="ff0000"><b>not active</b></font> )</i><p>';
   echo '<input type="submit" value="Update"></td></tr></form>';
 } //if
?>
   </tr>
   </table>
   </td>
   </tr>
 </table>
 </td>
<!-- body_text_eof //-->
</tr>
</table>
<!-- body_eof //-->

 

 

 

 

 

BTW, what does this do???

/// optional parameter to set max products per row:
$max_cols = 6;


L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Share this post


Link to post
Share on other sites

Nice PopTheTop, the menu works much better now! That was starting to get on my nerves, it was my next item to fix.

 

As far as the $max_cols = 6; It was just some old code along with the $i= stuff that was used when the module grouped everything into columns instead of rows, the columns are much easier to read and that is no longer used.

 

I think I prefer the 2 spacing in b/t the cells though as it is easier to read with all the columns more like a spreadsheet.. but thats just me.

 

I'll post your fixes as a new version.

 

For anyone that wants 0 spacing in between the cells or to add more spacing just find this line:

   echo '            <br><form method="post" action="quick_stockupdate.php">';
  echo '            <table width="100%" border="0" cellspacing=2 cellpadding=2>';

and change cellspacing= to whatever you want.


Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Share this post


Link to post
Share on other sites

Something about the reformating of the code in your version PopTheTop is causing some items with not active to roll onto a the next line so I will omit that part in the update.


Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Share this post


Link to post
Share on other sites
Something about the reformating of the code in your version PopTheTop is causing some items with not active to roll onto a the next line so I will omit that part in the update.

 

 

All you have to do is add NOWRAP to the table data. In fact, you can do that to all your TD tags like this...

 

<td class="dataTableContent" nowrap>


L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Share this post


Link to post
Share on other sites

What is wrapping? Is it products with long names?


L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Share this post


Link to post
Share on other sites

I have a screen reso;lution of 1024 x 768 and I have no problem of line wrapping. Just add the code as stated above and you will no longer have that problem, instead of wrapping, it will scroll off the screen a bit to the right but everything will stay on one line.

 

ie:

    while ($results = tep_db_fetch_array($sql2)) {
      $i++;
      echo '            <tr class="dataTableRow">';
  echo '              <td class="dataTableContent" nowrap> ' . $results['products_id'] . ' </td>';
      echo '              <td class="dataTableContent" nowrap> <input type="text" size="16" name="stock_update[' . $results['products_id'] . '][model]" value="' . $results['products_model'] . '"> </td>';
  echo '              <td class="dataTableContent" nowrap>   ' . $results['products_name'] . ' </td>';
  echo '              <td class="dataTableContent" nowrap>   <input type="text" size="6" name="stock_update[' . $results['products_id'] . '][weight]" value="' . $results['products_weight'] . '"> </td>';
  echo '              <td class="dataTableContent" nowrap>    <input type="text" size="9" name="stock_update[' . $results['products_id'] . '][price]" value="' . $results['products_price'] . '"> </td>';
  echo '              <td class="dataTableContent" nowrap>    <input type="text" size="4" name="stock_update[' . $results['products_id'] . '][stock]" value="' . $results['products_quantity'] . '">' . (($results['products_status'] == 0) ? '  <font color="ff0000"><b>not active</b></font>' : '  <font color="009933"><b>active</b></font> </td>');
      echo '            </tr>';
      if ($i == $max_cols) {
        $i = 0;
      }
   }


L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Share this post


Link to post
Share on other sites

Sorry, one more thing...

 

You could also remove the width="400" for the "Name" tag as follows

 

From:

    echo '              <td width="400" class="dataTableHeadingContent">    <b>Name</b></td>';

 

 

To this:

    echo '              <td class="dataTableHeadingContent">    <b>Name</b></td>';

 

 

 

ALSO...

 

I just noticed that some of the HTML coding was way off when I looked at the source code of the Admin Page.

 

 

Look for:

       if ($i == $max_cols) {
        $i = 0;
      }
   }
   echo '.........

 

 

Change the "echo" lines below that to look like this:

       if ($i == $max_cols) {
        $i = 0;
      }
   }
   echo '</table><br><br><input type="hidden" name="cat_id" value="' . $HTTP_POST_VARS['cat_id'] . '">';
   echo '<table border="0" width="100%" cellspacing=2 cellpadding=2><tr>';
   echo '<td align="center" colspan="10" class="smallText"><input type="checkbox" name="update_status" CHECKED>Check to set status on each individual product based on items in stock<br><i>( one or more in stock will become <font color="009933"><b>active</b></font> / zero in stock will become <font color="ff0000"><b>not active</b></font> )</i><p><input type="submit" value="Update"></td>';
   echo '</tr></table>';
   echo '</form>';

 

 

 

Ok, am I done yet, probably not, but I think so for now ;)


L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Share this post


Link to post
Share on other sites

Hi

 

I have just installed V2.4 - a contribution that coud be very usefull to my site.

- but i get nothing.

 

Just for information I have a lot of products (15000+) and many catagories

 

I have added the link from the admin catalog menu and followed the readme file - not mutch can go wrong here.

I also added the language line in the language file your language.php BOX_CATALOG_QUICK_STOCKUPDATE as it was missing from the readme file.

 

But when entering the Quick stock update page all I'm getting is an almost blank page.

 

This is a copy op the page

 

Quick Stock Update

 

Choose the category where you want to change the products within

 

 

 

 

? 2002 Tomorn K. - http://www.phpthailand.com

 

E-Commerce Engine Copyright ? 2003 osCommerce

osCommerce provides no warranty and is redistributable under the GNU General Public License

 

Powered by osCommerce

 

 

does anyone know what im missing

 

Christian

Share this post


Link to post
Share on other sites

yeap.. I also installed the latest version but i get the same thing..

It's only the first sentence - please select a category.. or smth like this.. and then it's empty.. I can't figure what is wrong..


==========

Share this post


Link to post
Share on other sites

Hmmm. that is funny. Well, not so funny for you guys. I have had no problems at all. Did you try installing version 3?


L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Share this post


Link to post
Share on other sites
Hmmm. that is funny. Well, not so funny for you guys. I have had no problems at all. Did you try installing version 3?

 

Hi

 

Thanks for your reply

 

There is no version 3. but I tryed version 2.3 , 2.3a and the latest 2.4 with the same result - sligtly different header text as it is changed in 2.4

 

I also looked at some of the earlyer versions to see if there was a file that was left behind - no result - so...

 

But could it be something to do with a timeout due to many products / categories ?

 

Christian

Share this post


Link to post
Share on other sites
Hi

 

Thanks for your reply

 

There is no version 3. but I tryed version 2.3 , 2.3a and the latest 2.4 with the same result - sligtly different header text as it is changed in 2.4

 

I also looked at some of the earlyer versions to see if there was a file that was left behind - no result - so...

 

But could it be something to do with a timeout due to many products / categories ?

 

Christian

 

 

Humm are you seeing the drop down? You need to select the category to see anything after the drop down box... I just redownloaded it to check and it works perfectly here. Maybe a timeout problem like you said, I only have about 150 products here.


Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Share this post


Link to post
Share on other sites
Humm are you seeing the drop down? You need to select the category to see anything after the drop down box... I just redownloaded it to check and it works perfectly here. Maybe a timeout problem like you said, I only have about 150 products here.

 

Hi

 

There is no drop down

only the top og page with the text

 

Quick Stock Update

 

Choose the category where you want to change the products within

 

Christian

Share this post


Link to post
Share on other sites

Well, then let's compare web browsers here...

 

Works just great for me:

Running MSIE v6.00.2800.1612


L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Share this post


Link to post
Share on other sites

Got only 'Choose the category where you want to change the products within' after install. What's wrong?

Share this post


Link to post
Share on other sites

Don't know. That is strange. Did you try to re-install it again or go through step by step on the instructions to be certain you installed it correctly to the "T"?

 

Did you load the page and viewed the HTML source code through your web browser to see if there is a problem with the HTML code that is causing it not to display correctly?


L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Share this post


Link to post
Share on other sites

I did reinstall but no help.

In html there is '<form method="post" action="quick_stockupdate.php">' and </form>, but there is nothing actual in between. (in fact, only this: "<table border="0"><tr> </tr></table>")

 

As far as I understand, there is only 3 steps, and no db changes.

Share this post


Link to post
Share on other sites

homewetbar> I only have about 150 products

christian glass> I have a lot of products (15000+)

 

Maybe that's the key?

 

I have about 2000 products and got same problem Christian had.

And, to make it clear, there is no point in browser comparing, as no info is outputting to html (my post above).

Share this post


Link to post
Share on other sites

Did you try installing an older version before the categories fix version?


Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Share this post


Link to post
Share on other sites

I do not know if this will make any difference but I got rid of the page per page display and now when I go into the catalog / products listings, all products are displayed on 1 page.


L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Share this post


Link to post
Share on other sites

Tried to install 2.0, 2.1, 2.3a - all the same. No output of actual data.

Share this post


Link to post
Share on other sites

Hi Pop the Top, you've saved the day in the devlopment of my site with the review system. Really great product. I love the idea of a quick product and price updater. As one of the hundreds who have installed QT Pro, it'd be a great addition to include a db search, determine if the product has any attributes associated with it and QT Pro is enabled, then list a subtree below each product with it.

 

I've attempted to do this myself, but with my PHP knowledge is still in the Dick and Jane, See Spot Run phase.

 

Quickly I realized, I may not be the right guy for the job. I expect to go live selling guitar pickups within a week or two. Integration with QT Pro would make the update product stock option, the true lifesaver for all OS shop merchants.

B)

P.S.

 

Not a necessity, but the language definition wasn't include in the directions.

 

Admin/Includes/Languages/english.php

 

Add:

 

define('BOX_CATALOG_QUICK_STOCKUPDATE', 'Quick Stock Update'); :thumbsup:

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

×