Latest News: (loading..)

estrich

Members
  • Content count

    13
  • Joined

  • Last visited

1 Follower

About estrich

Profile Information

  • Real Name
    Adam G.
  • Gender
    Male

Recent Profile Visitors

417 profile views
  1. @burtMaybe I'm missing something but this is what I am already doing in my revised execute function from yesterday: (using tep_db_num_rows...)
  2. Hmm - I'm a bit lost here... If I GROUP BY the products_id I will not get a count of all products_ids using COUNT(*) but a row for each products_id with the count of 1 - or am I missunderstanding something? SELECT count(*), p2c.products_id FROM products p, products_to_categories p2c WHERE p.products_id = p2c.products_id AND p.products_status = '1' and p2c.categories_id = '119' GROUP BY p2c.products_id count(*) products_id 1 424 1 453 1 503
  3. How about this change to the execute function(): <?php function execute() { global $PHP_SELF, $cPath, $current_category_id; if (basename($PHP_SELF) == 'index.php') { if ($current_category_id > 0) { $product_query = tep_db_query("SELECT p.products_id FROM products p, products_to_categories p2c WHERE p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$current_category_id . "'"); if(tep_db_num_rows($product_query) == 1) { $product = tep_db_fetch_array($product_query); if($product) { tep_redirect(tep_href_link('product_info.php', ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . (int)$product['products_id'])); } } } } } ?>
  4. no, because the $categories_products_query does only check if there are products in the category but not if these products have the status 1 (and are therefor visible).
  5. ht_categories_redirect.php in includes/modules/header_tags/ <?php class ht_categories_redirect { var $code = 'ht_categories_redirect'; var $group = 'header_tags'; var $title; var $description; var $sort_order; var $enabled = false; function __construct() { $this->title = MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_TITLE; $this->description = MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_DESCRIPTION; if ( defined('MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_STATUS') ) { $this->sort_order = MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_SORT_ORDER; $this->enabled = (MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_STATUS == 'True'); } } function execute() { global $PHP_SELF, $cPath, $current_category_id; if (basename($PHP_SELF) == 'index.php') { if ($current_category_id > 0) { $product_count = tep_count_products_in_category($current_category_id); if ($product_count == 1) { $product_query = tep_db_query("SELECT p.products_id FROM products p, products_to_categories p2c WHERE p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$current_category_id . "'"); $product = tep_db_fetch_array($product_query); if($product) { tep_redirect(tep_href_link('product_info.php', ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . (int)$product['products_id'])); } } } } } function isEnabled() { return $this->enabled; } function check() { return defined('MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_STATUS'); } function install() { tep_db_query("INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Categories Redirect Module', 'MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_STATUS', 'True', 'Do you want to enable the Categories Redirect module?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Sort Order', 'MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); } function remove() { tep_db_query("DELETE FROM configuration WHERE configuration_key IN ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_STATUS', 'MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_SORT_ORDER'); } } ?>
  6. Thanks burt, sure, I can try optimising it - if you have some pointers I'm all ears. Thinking about it, it would probably be good to combine the count query inside tep_count_products_in_category with the products_id query in my module somehow as both are operating on the same set - allthough I am not quite sure yet how to do that. cheers, estrich
  7. Sure. This is what I got so far: ht_categories_redirect.php in includes/modules/header_tags/ <?php class ht_categories_redirect { var $code = 'ht_categories_redirect'; var $group = 'header_tags'; var $title; var $description; var $sort_order; var $enabled = false; function __construct() { $this->title = MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_TITLE; $this->description = MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_DESCRIPTION; if ( defined('MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_STATUS') ) { $this->sort_order = MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_SORT_ORDER; $this->enabled = (MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_STATUS == 'True'); } } function execute() { global $PHP_SELF, $cPath, $current_category_id; if (basename($PHP_SELF) == FILENAME_DEFAULT) { if ($current_category_id > 0) { $product_count = tep_count_products_in_category($current_category_id); if ($product_count == 1) { $product_query = tep_db_query("SELECT p.products_id FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c WHERE p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$current_category_id . "'"); $product = tep_db_fetch_array($product_query); if($product) { tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . (int)$product['products_id'])); } } } } } function isEnabled() { return $this->enabled; } function check() { return defined('MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_STATUS'); } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Categories Redirect Module', 'MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_STATUS', 'True', 'Do you want to enable the Categories Redirect module?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_STATUS', 'MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_SORT_ORDER'); } } ?> and ht_categories_redirect.php in includes/languages/english/modules/header_tags/ <?php define('MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_TITLE', 'Automatic redirect to product page in categories with single product'); define('MODULE_HEADER_TAGS_CATEGORIES_REDIRECT_DESCRIPTION', 'Add automatic redirect to product page in categories with single product'); ?>
  8. Hey burt, thanks for the reply - thats good news! I am using the bootstrap gold version. So I implement a header tags module where I check if I am currently in a category and if so if the category only contains 1 item and then just redirect to the product page? Thanks again for the help. estrich
  9. Hello everyone, In our shop we have some categories containing only a single product. I am looking for a way to automatically redirect a user who is clicking on one of these category links directly to the product page. I could do this manually via htaccess but would prefer an automatic solution. Frankly I have no clue where to start without breaking a lot of stuff - does anybody have any pointers for me? Thanks in advance, estrich
  10. Thanks for all the suggestions - that already helped me a lot! I will be looking into the suggested add-ons and see what might fit best for our scenario. Thanks again, estrich
  11. Thanks for your input Dan! I may have worded my request badly. I don't need my customers to tag the products, I just want to tag them myself and then built a menu where the items query for products with a certain tag. Cheers, estrich
  12. Hi, I'm looking for an add-on which allows me to add custom tags to my products. I want to create a second menu (besides the categories list) with a list of properties (as in health properties) certain products have (one product can have more than one property - therefore needs more than one tag). The items on this list trigger a search for all products with a certain tag and list them. The properties list itself should not be generated dynamically. Could someone point me in the right direction? Thanks, estrich