chrometweaks.org

Help me to find the free iPage web host or free domain?

Click Here To View All Answers...


Quick question: Help me to find the free iPage web host or free domain? Hoping for any answer. Another question I got... Ok this is for all the people out there that have more then one sub category between products..

From the index.php New products by month are listed and once you get to the category products are listed it defines that list from it's current category..

Well I picked up this mod that is supposed to display the products from the sub categories listed below the current category. From what I can tell it's not working, I still only get new products for index and the last category the products no in between. The code is listed below I have been going insane trying to figure out what’s wrong but I am not the most skilled php coder there is. My main focus here is getting the new products to display right in sub category’s then converting this mod to do the same for bestsellers per category and sub category. Any help would be much appreciated..

Here is the support form for the Contribution I am using.

Http://forums.oscomm...pic.php?t=13925.

BTW: I am using osc snapshot 06/08/04.

<?php.

/*.

$Id: new_products.php,v 1.35 2003/09/08 13:25:44 project3000 Exp $.

***************************************************************************.

Contribution: Include all Subcategories for 'New Products', version 1.0.

Mod by Nils Petersson, 2004/05/02.

***************************************************************************.

OsCommerce, Open Source E-Commerce Solutions.

Http://www.oscommerce.com.

Copyright © 2003 osCommerce.

Released under the GNU General Public License.

*/.

?>.

?>.

<! new_products //>.

<?php.

If ( (isset($new_products_category_id)) || ($new_products_category_id == '0') ) { // in index.php.

$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from "TABLE_PRODUCTS" p left join "TABLE_SPECIALS" s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit "MAX_DISPLAY_NEW_PRODUCTS);.

} else { // in a category.

$cats[] = $new_products_category_id; // current catID as starting value.

// put cat-IDs of all cats nested in current branch into $cats array, go through all subbranches.

For($i=0;$i<count($cats);$i++) {.

$categorie_query = tep_db_query("select categories_id from "TABLE_CATEGORIES" where parent_id = '"(int)$cats[$i]"'");.

While ($categorie = tep_db_fetch_array($categorie_query)) {.

$cats[] = $categorie['categories_id'];.

}.

$cats=array_unique($cats); // sort out doubles.

}.

$num = (int) MAX_DISPLAY_NEW_PRODUCTS;.

$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from "TABLE_PRODUCTS" p left join "TABLE_SPECIALS" s on p.products_id = s.products_id, "TABLE_PRODUCTS_TO_CATEGORIES" p2c, "TABLE_CATEGORIES" c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id in (".implode(', ', $cats).") and p.products_status = '1' order by p.products_date_added desc limit "$num);.

}.

If (tep_db_num_rows($new_products_query) > 0) {.

$info_box_contents = array();.

$info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));.

New contentBoxHeading($info_box_contents);.

$row = 0;.

$col = 0;.

While ($new_products = tep_db_fetch_array($new_products_query)) {.

$new_products['products_name'] = tep_get_products_name($new_products['products_id']);.

$info_box_contents[$row][$col] = array('align' => 'center',.

'params' => 'class="smallText" width="33%" valign="top"',.

'text' => '<a href="'tep_href_link(FILENAME_PRODUCT_INFO, 'products_id='$new_products['products_id'])'">'tep_image(DIR_WS_IMAGES$new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)'</a><br><a href="'tep_href_link(FILENAME_PRODUCT_INFO, 'products_id='$new_products['products_id'])'">'$new_products['products_name']'</a><br>'$currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])));.

$col ++;.

If ($col > 2) {.

$col = 0;.

$row ++;.

}.

}.

New contentBox($info_box_contents);.

}.

?>.

<! new_products_eof //>.

Thank You.

Jason..

Comments (4)

I would like to know the answer too. Anyone here know what is the right answer. I'll do some poking around and get back to you if I find an good answer. You should email the people at iPage as they probably could give you an answer..

Comment #1

Hey Nils,.

Thanks for the quick reply. Yea I did see that in the readme I do have the MS2 installed as well as the snapshot I use the MS2 to make sure stuff works then I try to do conversions for the snapshots. I just forgot to say I had it working on the MS2..

I have for the most part recoded it to work with the snapshot but I am kind of stuck on the $cats part. I am not sure if I need something calling the cPath arrays or if I am just missing something from the database calling change..

Here is what I got:.

<?php.

/*.

 $Id: new_products.php,v 1.35 2003/09/08 13:25:44 project3000 Exp $.

 .

***************************************************************************.

Contribution: Include all Subcategories for 'New Products', version 1.0.

Mod by Nils Petersson, 2004/05/02.

***************************************************************************.

 osCommerce, Open Source E-Commerce Solutions.

 http://www.oscommerce.com.

 Copyright (c) 2003 osCommerce.

 Released under the GNU General Public License.

*/.

?>.

<! new_products //>.

<?php.

If ( (!isset($current_category_id)) || ($current_category_id == '0') ) {  // in index.php.

  $new_products = $osC_Database->query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from "TABLE_PRODUCTS" p left join "TABLE_SPECIALS" s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit "MAX_DISPLAY_NEW_PRODUCTS);.

} else {   // in a category.

$cats[] = $current_category_id; // current catID as starting value.

// put cat-IDs of all cats nested in current branch into $cats array, go through all subbranches.

For($i=0;$i<count($cats);$i++) {.

 $categorie = $osC_Database->query("select categories_id from "TABLE_CATEGORIES" where parent_id = '"(int)$cats[$i]"'");.

 while ($new_products->next()) {.

 $cats[] = $new_products->valueInt('cataegorie_id');.

 }.

 $cats=array_unique($cats); // sort out doubles.

}.

$num = (int) MAX_DISPLAY_NEW_PRODUCTS;.

$new_products = $osC_Database->query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from "TABLE_PRODUCTS" p left join "TABLE_SPECIALS" s on p.products_id = s.products_id, "TABLE_PRODUCTS_TO_CATEGORIES" p2c, "TABLE_CATEGORIES" c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id in (".implode(', ', $cats).") and p.products_status = '1' order by p.products_date_added desc limit "$num);.

}.

   $new_products->setCache('new_products-''-'$current_catagory_id, '720');.

   $new_products->execute();.

   if ($new_products->numberOfRows() > 0)  {.

$info_box_contents = array();.

$info_box_contents[] = array('text' => sprintf( strftime('%B')));.

$row = 0;.

$col = 0;.

$info_box_contents = array();.

While ($new_products ->next()) {.

  $new_products = tep_get_products_name($new_products->valueInt('products_id'));.

  $specials_price = tep_get_products_special_price($new_products->valueDecimal('products_price'), $new_products->valueInt('products_tax_class_id'));.

 .

                                   $info_box_contents[$row][$col] = array('align' => 'center',.

                    'params' => 'class="smallText" width="33%" valign="top"',.

                    'text' => '<a href="'tep_href_link(FILENAME_PRODUCT_INFO, 'products_id='$new_products->valueInt('products_id'))'">'tep_image(DIR_WS_IMAGES$new_products->value('products_image'), $new_products->value('products_name'), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)'</a><br><a href="'tep_href_link(FILENAME_PRODUCT_INFO, 'products_id='$new_products->valueInt('products_id'))'">'$new_products->value('products_name')'</a><br>'$products_price);.

  $col ++;.

  if ($col > 2) {.

   $col = 0;.

   $row ++;.

  }.

}.

New contentBox($info_box_contents);.

}.

?>.

<! new_products_eof //>.

When I run the page I get:.

Fatal error: Call to a member function on a non-object in ...catalog/includes/modules/new_products.php on line 32.

Any help would be appreciated..

Jason..

Comment #2

Found the error:.

Line: 32 and 33.

While ($new_products->next()) {.

 $cats[] = $new_products->valueInt('cataegorie_id');.

Changed it to.

While ($categorie->next()) {.

 $cats[] = $categorie->valueInt('cataegorie_id');.

Now I do not get any errors but I am not getting anything when the page loads. I know there is new products in there, and suggestions?.

Thank.

Jason..

Comment #3

Hi jason,.

I'm not sure, as I don't know the snapshot and what the new stuff like valueInt does, but this.

Doesn't look right to me..

Nils..

Comment #4

Thank you, Thank you, Thank you for this contrib. I have been tearing what's left of my hair out...trying to fix this problem. BTW for those who live by the motto "if it ain't broke don't fix it" this will work with MS1 if you are replacing the new_products.php v1.34 with this one..

Comment #5


This question was taken from a support group/message board and re-posted here so others can learn from it.