Hallo beisammen, Ich versuche gerade die Kategorieseiten um products_date_added zu erweitern. Läuft auch, aber das einzige was ich neu brauche ist ein simples "p.product_date_added, " in der MySQL Query. Gibts auch einen Möglichkeit, an $this->sql_query im Overload ranzukommen? Dann Wäre der Code -99%. Theme gibt das Datum natürlich bereits Dank erweiterung Smarty Variable aus. /GXmodules/ff-webdesigner/custom/Shop/Overloads/ProductListingContentControl/more_details_ProductListingContentControl.inc.php Inhalt: PHP: class more_details_ProductListingContentControl extends more_details_ProductListingContentControl_parent{ public function build_default_sql() { $t_uninitialized_array = $this->get_uninitialized_variables(array( 'current_category_id', 'customer_country_id', 'customer_zone_id', 'customers_fsk18_display', 'customers_status_id', 'languages_id', 'show_price_tax', )); if (empty($t_uninitialized_array)) { //fsk18 lock $t_fsk_lock = ''; if ($this->customers_fsk18_display == '0') { $t_fsk_lock = ' AND p.products_fsk18 != 1 '; } $t_select_part = ''; $t_from_part = ''; $t_where_part = ''; // sorting query $t_sorting_query = xtc_db_query("SELECT `products_sorting`, `products_sorting2` FROM " . TABLE_CATEGORIES . " WHERE `categories_id` = '" . $this->current_category_id . "'"); $t_sorting_data_array = xtc_db_fetch_array($t_sorting_query); if (!$t_sorting_data_array['products_sorting']) { $t_sorting_data_array['products_sorting'] = 'pd.products_name'; } elseif ($t_sorting_data_array['products_sorting'] === 'p.products_sort') { $t_sorting_data_array['products_sorting'] .= ' ' . $t_sorting_data_array['products_sorting2'] . ', p.products_id'; } $t_sorting = ' ORDER BY ' . $t_sorting_data_array['products_sorting'] . ' ' . $t_sorting_data_array['products_sorting2'] . ' '; // We show them all $t_group_check = ''; if (GROUP_CHECK == 'true') { $t_group_check = " AND p.group_permission_" . $this->customers_status_id . " = 1 "; } // sorting $t_orderby = ''; if (isset($this->listing_sort)) { $coo_listing_manager = MainFactory::create_object('ListingManager'); $t_orderby = $coo_listing_manager->get_sql_sort_part($this->listing_sort); if ($t_orderby != '') { $t_sorting = $t_orderby; } } else { $t_sorting .= ', p.products_sort ASC'; } // sort by price if (strpos($t_orderby, 'p.products_price') !== false) { if ($this->show_price_tax != 0) { $t_select_part = ", ROUND(IF(s.status = '1' AND p.products_id = s.products_id, s.specials_new_products_price, p.products_price) * (IF(p.products_tax_class_id = 0,0,tax_rate)/100+1), 2) AS final_price "; $t_from_part = "LEFT JOIN " . TABLE_TAX_RATES . " AS tr ON (p.products_tax_class_id = tr.tax_class_id OR p.products_tax_class_id = 0) LEFT JOIN " . TABLE_ZONES_TO_GEO_ZONES . " AS gz ON (tr.tax_zone_id = gz.geo_zone_id AND gz.zone_country_id = '" . $this->customer_country_id . "') "; $t_where_part = " AND (gz.zone_id = '0' OR gz.zone_id = '" . $this->customer_zone_id . "') "; } else { $t_select_part = ", ROUND(IF(s.status = '1' AND p.products_id = s.products_id, s.specials_new_products_price, p.products_price), 2) AS final_price "; } $t_sorting = str_replace('p.products_price', 'final_price', $t_sorting); } $this->sql_query = "SELECT DISTINCT p.products_fsk18, p.products_shippingtime, p.use_properties_combis_shipping_time, p.products_model, p.products_ean, pd.products_name, m.manufacturers_name, p.products_quantity, p.products_image, p.products_image_w, p.products_image_h, p.products_weight, p.gm_show_weight, pd.products_short_description, pd.products_description, pd.gm_alt_text, pd.products_meta_description, p.products_id, p.manufacturers_id, p.products_price, p.products_vpe, p.products_vpe_status, p.products_vpe_value, p.products_discount_allowed, p.products_tax_class_id " . $t_select_part . " FROM " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " AS pd ON (pd.products_id = p.products_id) LEFT JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " AS ptc ON (ptc.products_id = p.products_id) LEFT JOIN " . TABLE_MANUFACTURERS . " AS m ON (m.manufacturers_id = p.manufacturers_id) LEFT JOIN " . TABLE_SPECIALS . " AS s ON (s.products_id = p.products_id) " . $t_from_part . " WHERE p.products_status = 1 AND pd.language_id = '" . $this->languages_id . "' AND ptc.categories_id = '" . $this->current_category_id . "' " . $t_where_part . " " . $t_group_check . " " . $t_fsk_lock . " " . $t_sorting; } else { trigger_error("Variable(s) " . implode(', ', $t_uninitialized_array) . " do(es) not exist in class " . get_class($this) . " or is/are null", E_USER_ERROR); } } }
Die Variable "sql_query" ist eine Klassenvariable, auf die man auch im Overload zugreifen kann. Mit dem Code: PHP: class more_details_ProductListingContentControl extends more_details_ProductListingContentControl_parent{ public function build_default_sql() { parent::build_default_sql(); // Hier kann man jetzt die Variable manipulieren // z. B. $this->sql_query = ....... }} sollte man die Variable ändern können(wenn ich nichts übersehen habe). Aber achte darauf, dass die Select-Anweisung wegen dem DISTINCT evtl. andere Datensätze zurück gibt, mit dem neuen Abfragefeld.
DICKES DANKE KAI! läuft jetzt mit minmalem code. PHP: class more_details_ProductListingContentControl extends more_details_ProductListingContentControl_parent{ public function build_default_sql() { parent::build_default_sql(); $this->sql_query = str_replace("SELECT DISTINCT","SELECT DISTINCT p.products_date_added,",$this->sql_query); }} wegen DISTINCT: der counter unten auf der seite gibt genau die gleiche anzahl aus wie ohne overload. 13411. dann sollte alles passen denk ich. soweit ich DISTINCT verstehe: das wählt jede zeile aus in dem WENIGSTENS eines der SELECT felder unteschiedlich ist. korrekt?