function initQuery($params) { $tables = Manufacturers::getTables(); $tables_ctl = Catalog::getTables(); $m = $tables['manufacturers']['columns']; $pa = $tables_ctl['product_attributes']['columns']; $setting_filtering = $params['setting_filtering']; $setting_nonempty = $params['setting_nonempty']; $zone = $params['zone']; $b_only_active = $params['b_only_active']; $return_all = $params['return_all']; $_ids = $params['_ids']; $this->addSelectTable('manufacturers'); $this->addSelectField("DISTINCT(" . $m['manufacturer_id'] . ")", 'id'); $this->addSelectField($m['manufacturer_name'], 'value'); if ($b_only_active === true) { $this->WhereValue($m['manufacturer_active'], DB_EQ, DB_TRUE); } if ($return_all == false && $setting_nonempty == "HIDE_EMPTY" && $zone == "CustomerZone") { $this->addSelectTable('product_attributes'); if ($b_only_active === true) { $this->WhereAND(); } $this->WhereField($m['manufacturer_id'], DB_EQ, $pa['attr_value']); $this->WhereAND(); $this->WhereValue($pa['a_id'], DB_EQ, modApiFunc('Catalog', 'getManufacturerAttrId')); if (!empty($_ids)) { foreach ($_ids as $i) { $ids[] = $i['product_id']; } $this->WhereAND(); $this->WhereField($pa['p_id'], DB_IN, '(' . implode(',', $ids) . ')'); } } $this->SelectOrder($m['sort_order'], 'ASC'); }
/** * Uninstalls the module. * It deletes all module tables. * * The uninstall() method is called statically. * To call other methods of this class from this method, * the static call is used, for example, * Catalog::getTables() instead of $this->getTables() */ function uninstall() { $query = new DB_Table_Delete(Catalog::getTables()); global $application; $application->db->getDB_Result($query); }
function initQuery($params) { $pid = $params['pid']; $tables = Catalog::getTables(); $c = $tables['products_to_categories']['columns']; $this->addSelectField($c['category_id'], 'mcats'); $this->WhereValue($c['product_id'], DB_EQ, $pid); }
function initQuery($params) { $id = $params['it_id']; $tables = Catalog::getTables(); $it = $tables['input_types']['columns']; $itv = $tables['input_type_values']['columns']; foreach ($it as $k => $v) { $this->addSelectField($v); } foreach ($itv as $k => $v) { if ($k != 'value') { $this->addSelectField($v); } else { $this->setMultiLangAlias('_ml_value', 'input_type_values', $itv['value'], $itv['id'], 'Catalog'); $this->addSelectValue($this->getMultiLangAlias('_ml_value'), 'input_type_value'); } } $this->WhereValue($it['id'], DB_EQ, $id); $this->WhereAND(); $this->WhereField($itv['it_id'], DB_EQ, $it['id']); $this->SelectOrder($itv['id'], 'ASC'); }
function initQuery($params) { $tables = Customer_Reviews::getTables(); $crtable = $tables['customer_reviews']['columns']; $rtable = $tables['customer_reviews_rates']['columns']; $rltable = $tables['customer_reviews_rate_list']['columns']; $product_tables = Catalog::getTables(); $ptable = $product_tables['products']['columns']; $patable = $product_tables['product_attributes']['columns']; $ptatable = $product_tables['product_type_attributes']['columns']; $this->addSelectTable('customer_reviews'); $this->addSelectTable('customer_reviews_rates'); $this->addSelectTable('customer_reviews_rate_list'); $this->addSelectField($crtable['product_id']); $this->addSelectField('SUM(' . $rtable['rate'] . ')', 'total_rate'); $this->addSelectField('COUNT(' . $rtable['rate'] . ')', 'total_count'); // getting customer_review value for selected product // attribute_id = CUSTOMER_REVIEWS_PRODUCT_ATTRIBUTE_ID $attribute_id = modApiFunc('Catalog', 'getCustomerReviewsAttrId'); $this->addLeftJoinOnConditions('product_attributes', array($crtable['product_id'], DB_EQ, $patable['p_id'], DB_AND, $patable['a_id'], DB_EQ, $attribute_id)); $this->addLeftJoin('products', $crtable['product_id'], DB_EQ, $ptable['id']); $this->addLeftJoinOnConditions('product_type_attributes', array($ptable['pt_id'], DB_EQ, $ptatable['pt_id'], DB_AND, $ptatable['type_attr_visible'], DB_EQ, '1', DB_AND, $ptatable['a_id'], DB_EQ, $attribute_id)); $this->addSelectField('IF(' . $patable['attr_value'] . ' IS NULL OR ' . $ptatable['a_id'] . ' IS NULL, 0, ' . $patable['attr_value'] . ')', 'product_cr'); $this->WhereField($crtable['cr_id'], DB_EQ, $rtable['cr_id']); $this->WhereAND(); $this->WhereField($rtable['cr_rl_id'], DB_EQ, $rltable['cr_rl_id']); $this->WhereAND(); // show only visible rates $this->WhereValue($rltable['visible'], DB_EQ, 'Y'); $this->WhereAND(); // show only approved reviews $this->WhereValue($crtable['status'], DB_EQ, 'A'); if (isset($params['product_id'])) { $this->WhereAND(); $this->WhereValue($crtable['product_id'], DB_EQ, $params['product_id']); } $this->SelectGroup($crtable['product_id']); }