NuDreamer Posted January 28, 2013 Share Posted January 28, 2013 I have been customizing a version of the "featured Products" module, in order to create a new version of my catalog pages. It is highly customized, and you can see what I am doing here: http://www.tacticalbootstore.com/boots-511-tactical-c-392.html The idea, is that I want to be able to display the products in the subcategories, on the categories page, with a small description. This is mostly for SEO purposes. However.. for some reason.. the code is not displaying the product name! I have the product price output.. but the product name refuses to show! I have been staring at it for hours and can't figure it out. i was hoping a fresh pair of eyes would see what I missed. The code is showing below: if ($current_category_id == "392") { echo "<div style='border-width: 1px; border-style: solid; border-color: e6e6e6; padding:2px; margin: 5px;'>"; if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) { $category_query = tep_db_query("select distinct categories_id from ". TABLE_PRODUCTS_TO_CATEGORIES ); $cids = array(); while ($categories = tep_db_fetch_array($category_query)) { array_push($cids, $categories["categories_id"]); } $cid = $cids[rand(0, count($cids) - 1)]; // removed order by p.products_date_added desc $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 " . " where p.products_id = p2c.products_id and products_status = '1' and (p2c.categories_id = 399)" . "order by rand() limit " . MAX_DISPLAY_NEW_PRODUCTS); echo "<h2><a href='http://www.tacticalbootstore.com/boots-511-tactical/511-atac-c-392_399.html'>5.11 ATAC Boots</a></h2><br /> The ATAC Series or better known as 'All Terrain, All Condition' is proven to be the best tactical boot produced by 5.11. Within this superior quality boot you have full grain leather and nylon uppers. Also to protect you the boot is lined with moisture wicking and antibacterial material. For the best stability we added oil and slip resistance and a quiet outsole so that you can easily approach anyone undetected. When trying to create the best comfort we added Dual Density Polyou cushioning and open cell foam cushioning this way you know it's easy to handle long distances. The ATAC Series will give you the best tactical advantage in any fight, if you need tactical gear, choose 5.11."; } else { $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 = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by rand() limit " . MAX_DISPLAY_NEW_PRODUCTS); } $row = 0; $col = 0; $info_box_contents = array(); while ($new_products = tep_db_fetch_array($new_products_query)) { $new_products['products_name'] = tep_get_products_name($new_products['products_id']); while ($new_products = tep_db_fetch_array($new_products_query)) { $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*2, SMALL_IMAGE_HEIGHT*2) . '</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); echo "</div>"; The general idea is, I would like to develop this into a module if I can get the bugs worked out of it. Thanks so much in advance for anyone who can help me with this! Link to comment Share on other sites More sharing options...
NuDreamer Posted January 29, 2013 Author Share Posted January 29, 2013 RESOLVED! In case anyone else is interested. What I am doing, is basically rewriting my categories page, to display the subcategories WITH products. This allows me to put a nice little blurb about each subcategory in a tasty little tidbit for google and other search engines. A keyword rich page if you will that links to my products. I will post the code I used below for anyone else who may be interested in something along these lines at any point in time. Current version of the shop is RCA 2.2 This can easily be adapted for 2.3. preferably I would like to be able to integrate Header Tags SEO into this.. so the Header Tags Description text will display instead of having to write it in yourself and potentially doing double the work. Its on my to-do list, or if anyone else figures it out, by all means go for it. Code is below. <?php // Name Parent Category if ($current_category_id == "392") { // BoF SubCategories Display Block. Duplicate the code between the BoF SubCategories Display Block, to EoF SubCategories Display Block. echo "<div style='border-width: 1px; border-style: solid; border-color: e6e6e6; padding:2px; margin: 5px;'>"; // draw a nice box around our display // Pick Your SubCategory. Replace the XXX in this block with your subcategory ID. if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) { $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 " . ", ". TABLE_PRODUCTS_TO_CATEGORIES . " p2c " . "where p.products_id = p2c.products_id and products_status = '1' and p2c.categories_id = XXX " . "order by rand() limit " . MAX_DISPLAY_NEW_PRODUCTS); // SEO Text Begins Here echo "Place your subcategories text blurb here."; } else { $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 = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by rand() limit " . MAX_DISPLAY_NEW_PRODUCTS); } $row = 0; $col = 0; $info_box_contents = array(); 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*1.5, SMALL_IMAGE_HEIGHT*1.5) . '</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); echo "</div>"; // EoF SubCategories Display Block. The code between here and the BoF can be used over and over again for as many SubCategories as you wish. } ?> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.