jodo Posted June 7, 2004 Posted June 7, 2004 Please forgive me if this is too OT for this fine thread but I figure it's "ok" since it does involve master products. I need help getting all_products to sort on sort_order as opposed to just categories_id. I have hacked away at this all afternoon and my sql skills are not up to it. I have it working fine displaying only master products and no slaves but need to control the order in which the categories appear. So I want only master_products (no slaves), sorted by their category, in the sort_order established in the admin. Here is the pertinant code from all_products.php. $included_categories_query = tep_db_query("SELECT c.categories_id, c.parent_id, cd.categories_name FROM " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd WHERE c.categories_id = cd.categories_id AND cd.language_id = FLOOR($languages_id)"); $inc_cat = array(); while ($included_categories = tep_db_fetch_array($included_categories_query)) { $inc_cat[] = array ( 'id' => $included_categories['categories_id'], 'parent' => $included_categories['parent_id'], 'name' => $included_categories['categories_name']); } $cat_info = array(); for ($i=0; $i<sizeof($inc_cat); $i++) $cat_info[$inc_cat[$i]['id']] = array ( 'parent'=> $inc_cat[$i]['parent'], 'name' => $inc_cat[$i]['name'], 'path' => $inc_cat[$i]['id'], 'link' => '' ); for ($i=0; $i<sizeof($inc_cat); $i++) { $cat_id = $inc_cat[$i]['id']; while ($cat_info[$cat_id]['parent'] != 0){ $cat_info[$inc_cat[$i]['id']]['path'] = $cat_info[$cat_id]['parent'] . '_' . $cat_info[$inc_cat[$i]['id']]['path']; $cat_id = $cat_info[$cat_id]['parent']; } $link_array = split('_', $cat_info[$inc_cat[$i]['id']] ['path']); for ($j=0; $j<sizeof($link_array); $j++) { $cat_info[$inc_cat[$i]['id']]['link'] .= ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $cat_info[$link_array[$j]]['path']) . '"><nobr>' . $cat_info[$link_array[$j]]['name'] . '</nobr></a> » '; } } $products_query = tep_db_query("SELECT p.products_id, pd.products_name, pc.categories_id, p.products_master_status FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " pc WHERE p.products_id = pd.products_id AND p.products_id = pc.products_id AND p.products_status = 1 AND p.products_master_status = 1 AND pd.language_id = FLOOR($languages_id) ORDER BY pc.categories_id, pd.products_name"); thanks Quote
dbasch Posted June 7, 2004 Posted June 7, 2004 Quick question. Does Master Products work with Easy Populate? Quote
Guest Posted June 7, 2004 Posted June 7, 2004 Quick question. Does Master Products work with Easy Populate? Yes - there is a contribution for it - dunno the link, you will need to search contributions :) Matti Quote
dbasch Posted June 7, 2004 Posted June 7, 2004 Nevermind, I found the answer here: http://www.oscommerce.com/community/contributions,500 :huh: Quote
dbasch Posted June 7, 2004 Posted June 7, 2004 I would say you have not updated catalog/includes/application_top.php... I would say you are right! It took me a while to find it, but once I pasted in the updated logic everything worked just as I had hoped. Thank you! I must say, it seems a bit strange to me that in the 6 months that have passed since this patch was posted, no one has seen fit to add an updated application_top.php to the contribution stack. Would it make sense for someone to do that? If not, why not? If so, should I go ahead and do it? (Am I allowed to do it?) :blink: Thanks again, Haephestus Hello Again, I installed Master Products - 1.1.5 and am getting the same behavior. I can create Master products and Slaves but I can't add any of them to my cart. I dug through this thread for an hour but could not find the aplication_top.php solution that is referred to. Can anyone help me? Thanks! Quote
♥ecartz Posted June 7, 2004 Posted June 7, 2004 They are just saying that it is likely that you missed some changes to application_top.php that need to be made. I would recommend using a file comparer to compare your file to the one that comes with the contribution. I use ExamDiff and Matti uses Beyond Compare. Either should work for your needs. ExamDiff has a free beer version; I think that Beyond Compare is only available for free as a 30 day trial. Hth, Matt Quote Always back up before making changes.
Guest Posted June 7, 2004 Posted June 7, 2004 Has anyone any news on the attributes update by Brian? I think about 5-6 pages back he said he had it sorted and would release in about a week or so. h8 to repeat myself but I need to now if there is light at the end of the tunnel, I would like to use the master products but I need it with attributes if possible, Brian mentioned that he had sorted, and he would package once he had tested further for another week. I have searched through dozens of contributions to do what I need and MP woth attributes would solve my problem. Thx in advance for any help. :D Quote
ryanf Posted June 7, 2004 Posted June 7, 2004 If you follow the posts between brian and myself starting about 7 pages back or so, you can figure out how to get attributes working on your site. Quote If I was crafty, this would be a funny signature.
dbasch Posted June 7, 2004 Posted June 7, 2004 They are just saying that it is likely that you missed some changes to application_top.php that need to be made. I would recommend using a file comparer to compare your file to the one that comes with the contribution. I use ExamDiff and Matti uses Beyond Compare. Either should work for your needs. ExamDiff has a free beer version; I think that Beyond Compare is only available for free as a 30 day trial. Hth, Matt I was quoting from someone else's posting before. In my case, I have installed a fresh copy of OSCommerce and then installed Master Products - 1.1.5. I have created a sample master and slave products: Hanes XL T-Shirt: Blue Red I have hidden the slaves which gives me: If I select a quantity of 1 for Red and Blue and the master product and then select 'Add to Cart' the items are not added to the cart. That is where I am stuck. Does v1.1.5 not work as released? Thanks everyone :ph34r: Quote
Guest Posted June 7, 2004 Posted June 7, 2004 If you follow the posts between brian and myself starting about 7 pages back or so, you can figure out how to get attributes working on your site. I appreciate the code you have and brian posted between you is able to get attributes to work, however that was not my question I asked if Brian was any further ahead in his release of a package version for installation into a new osc shop. The code you and Brain released is a little unclear for none coders to install, since you have other contrib code in also. Quote
jodo Posted June 7, 2004 Posted June 7, 2004 Derek, Try removing qty for the master in your admin. Also the price. You actually only have two items for sale, blue and red slaves of the master. The master is not for sale. And therefor has no qty or price. See if that helps. Quote
dbasch Posted June 7, 2004 Posted June 7, 2004 Derek, Try removing qty for the master in your admin. Also the price. You actually only have two items for sale, blue and red slaves of the master. The master is not for sale. And therefor has no qty or price. See if that helps. I removed the qty and price from the master. That removed the qty pulldown from the master but the selected colors are still not being added to the cart. Any other suggestions? :( Quote
jodo Posted June 7, 2004 Posted June 7, 2004 Hmmm... Are these only models in your db named red and blue? Quote
dbasch Posted June 7, 2004 Posted June 7, 2004 Hmmm... Are these only models in your db named red and blue? Yes, they are the only ones. I made a new products with a yellow color just to be sure and it did not work either. :angry: :( Quote
jodo Posted June 7, 2004 Posted June 7, 2004 And can products that are neither master or slave be added to the cart? And can an item marked as master but with no slaves be added to the cart? Quote
dbasch Posted June 8, 2004 Posted June 8, 2004 And can products that are neither master or slave be added to the cart? And can an item marked as master but with no slaves be added to the cart? Products that are neither master or slave can only be added if you select the 'buy now' button. Otherwise, they display the same behavior as the others. Items that are masters with no slaves display the same behavior. Weird huh? I don't know why I would have this problem with the default installations? <_< Quote
jodo Posted June 8, 2004 Posted June 8, 2004 post your case master_list_options from /includes/modules/mastrer_listing.php Quote
dbasch Posted June 8, 2004 Posted June 8, 2004 post your case master_list_options from /includes/modules/mastrer_listing.php Here is the whole shebang. I have not altered anything from the original file (to my knowledge). B) Thanks for the help! <?php /* $Id: master_listing.php osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Master Products MS2 - JOHNSON - 05/07/2003 [email protected] Copyright (c) 2003 Suomedia - Dynamic Content Management Released under the GNU General Public License */ $listing_split = new splitPageResults($master_sql, MAX_DISPLAY_SEARCH_RESULTS, 'products_master'); if ( ($listing_split->number_of_rows > 0) && ( (MASTER_PREV_NEXT_BAR_LOCATION == '1') || (MASTER_PREV_NEXT_BAR_LOCATION == '3') ) ) { ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td> <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td> </tr> </table> <?php } $list_box_contents = array(); for ($col=0, $n=sizeof($column_list); $col<$n; $col++) { switch ($column_list[$col]) { case 'MASTER_LIST_MODEL': $lc_text = TABLE_HEADING_MODEL; $lc_align = ''; break; case 'MASTER_LIST_NAME': $lc_text = TABLE_HEADING_PRODUCTS; $lc_align = ''; break; case 'MASTER_LIST_DESCRIPTION': $lc_text = TABLE_HEADING_DESCRIPTION; $lc_align = 'center'; break; case 'MASTER_LIST_ATTRIBUTES': $lc_text = TABLE_HEADING_ATTRIBUTES; $lc_align = 'center'; break; case 'MASTER_LIST_MANUFACTURER': $lc_text = TABLE_HEADING_MANUFACTURER; $lc_align = ''; break; case 'MASTER_LIST_PRICE': $lc_text = TABLE_HEADING_PRICE; $lc_align = 'right'; break; case 'MASTER_LIST_QUANTITY': $lc_text = TABLE_HEADING_QUANTITY; $lc_align = 'right'; break; case 'MASTER_LIST_WEIGHT': $lc_text = TABLE_HEADING_WEIGHT; $lc_align = 'right'; break; case 'MASTER_LIST_IMAGE': $lc_text = TABLE_HEADING_IMAGE; $lc_align = 'center'; break; case 'MASTER_LIST_BUY_NOW': $lc_text = TABLE_HEADING_BUY_NOW; $lc_align = 'center'; break; } if ( ($column_list[$col] != 'MASTER_LIST_BUY_NOW') && ($column_list[$col] != 'MASTER_LIST_IMAGE' && ($column_list[$col] != 'MASTER_LIST_MULTIPLE' && ($column_list[$col] != 'MASTER_LIST_DESCRIPTION'))) ) { $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text); } $list_box_contents[0][] = array('align' => $lc_align, 'params' => 'class="productListing-heading"', 'text' => ' ' . $lc_text . ' '); } if ($listing_split->number_of_rows > 0) { $rows = 0; $master_query = tep_db_query($listing_split->sql_query); while ($listing = tep_db_fetch_array($master_query)) { $rows++; if (($rows/2) == floor($rows/2)) { $list_box_contents[] = array('params' => 'class="productListing-even"'); } else { $list_box_contents[] = array('params' => 'class="productListing-odd"'); } $cur_row = sizeof($list_box_contents) - 1; for ($col=0, $n=sizeof($column_list); $col<$n; $col++) { $lc_align = ''; $lc_params = ''; switch ($column_list[$col]) { case 'MASTER_LIST_MODEL': $lc_align = ''; $lc_text = ' ' . $listing['products_model'] . ' '; break; case 'MASTER_LIST_NAME': $lc_align = ''; if (isset($HTTP_GET_VARS['manufacturers_id'])) { $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>'; } else { $lc_text = ' ' . $listing['products_name'] . '</a> '; } break; case 'MASTER_LIST_DESCRIPTION': $lc_align = ''; $lc_text = ' ' . osc_trunc_string(strip_tags($listing['products_description'], '<a><b><em><font><i><s><span><strong><sub><sup><u>'), MASTER_LIST_DESCRIPTION_LENGTH) . ' '; break; case 'MASTER_LIST_MANUFACTURER': $lc_align = ''; $lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a> '; break; case 'MASTER_LIST_PRICE': $lc_align = 'right'; if (tep_not_null($listing['specials_new_products_price'])) { $lc_text = ' <s>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span> '; } else { $lc_text = ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' '; } break; case 'MASTER_LIST_QUANTITY': $lc_align = 'center'; $lc_text = ' ' . $listing['products_quantity'] . ' '; break; case 'MASTER_LIST_WEIGHT': $lc_align = 'right'; $lc_text = ' ' . $listing['products_weight'] . ' '; break; case 'MASTER_LIST_IMAGE': $lc_align = 'center'; if (isset($HTTP_GET_VARS['manufacturers_id'])) { $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; } else { $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> '; } break; case 'MASTER_LIST_BUY_NOW': $lc_align = 'center'; $lc_valign = 'top'; if ((STOCK_CHECK == 'true')&&(tep_get_products_stock($listing['products_id']) < 1)) { $lc_text = TEXT_STOCK; } elseif ((STOCK_CHECK == 'false')&&(tep_get_products_stock($listing['products_id']) < 1)) { $qty_array = array(); for ($i=0; $ns = 20, $i <= $ns; $i++) { $qty_array[] = array('id' => $i, 'text' => $i); $lc_text = tep_draw_pull_down_menu('Qty_ProdId_' . $listing['products_id'], $qty_array); } } else { $quantity = tep_get_products_stock($listing['products_id']); $qty_array = array(); for ($i=0; $ns = (($quantity < 20) ? $quantity : 20), $i <= $ns; $i++) { $qty_array[] = array('id' => $i, 'text' => $i); $lc_text = tep_draw_pull_down_menu('Qty_ProdId_' . $listing['products_id'], $qty_array); } } break; } $list_box_contents[$cur_row][] = array('align' => $lc_align, 'valign' => $lc_valign, 'params' => 'class="productListing-data"', 'text' => $lc_text); } } new productListingBox($list_box_contents); } else { $list_box_contents = array(); $list_box_contents[0] = array('params' => 'class="productListing-odd"'); $list_box_contents[0][] = array('params' => 'class="productListing-data"', 'text' => TEXT_NO_PRODUCTS); new productListingBox($list_box_contents); } ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> </table> <?php if ( ($listing_split->number_of_rows > 0) && ((MASTER_PREV_NEXT_BAR_LOCATION == '2') || (MASTER_PREV_NEXT_BAR_LOCATION == '3')) ) { ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td> <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td> </tr> </table> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } ?> Quote
jodo Posted June 8, 2004 Posted June 8, 2004 You appear to be missing the section CASE 'MASTER_LIST_OPTIONS' which I have before case 'MASTER_LIST_BUY_NOW' Quote
ryanf Posted June 8, 2004 Posted June 8, 2004 master list options is only for inserting attributes into the slaves. I think your problem is with application_top, redo that part of the installation and if it still doesn't work, post just the add_slave part of application_top Ryan Quote If I was crafty, this would be a funny signature.
dbasch Posted June 8, 2004 Posted June 8, 2004 master list options is only for inserting attributes into the slaves. I think your problem is with application_top, redo that part of the installation and if it still doesn't work, post just the add_slave part of application_top Ryan I replaced it and I am still getting the same behavior. Here is the code requested: case 'add_slave' : while ( list( $key, $val ) = each( $HTTP_POST_VARS ) ) { if (substr($key,0,11) == "Qty_ProdId_") { $prodId = substr($key,11); $qty = $val; if ($qty <= 0 ) continue; $cart->add_cart($prodId, $cart->get_quantity(tep_get_uprid($prodId, $HTTP_POST_VARS['id']))+($qty), $HTTP_POST_VARS['id']); } } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; Thanks ;) Quote
dbasch Posted June 8, 2004 Posted June 8, 2004 master list options is only for inserting attributes into the slaves. I think your problem is with application_top, redo that part of the installation and if it still doesn't work, post just the add_slave part of application_top Ryan Just to double check, the installation should consist cutting and pasting the files and running the sql aqainst the DB, correct? :huh: Quote
tmac2104 Posted June 9, 2004 Posted June 9, 2004 I've read through about 20 pages of this thread trying to find an answer... but I need to eat. So if anyone can spot an error right off the bat you will be crowned my king. http://tmac2104.zer0host.com/catalog/index.php all my categories are just tester categories... Thanks Trevor Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.