public function getInformation($item_id)
 {
     $cache = 'wss_information.' . $item_id;
     $result = Sumo\Cache::find($cache);
     if (is_array($result) && count($result)) {
         return $result;
     }
     $result = $this->query("SELECT * FROM PREFIX_information_description WHERE information_id = :id AND language_id = :lid", array('id' => $item_id, 'lid' => $this->config->get('language_id')))->fetch();
     Sumo\Cache::set($cache, $result);
     return $result;
 }
Exemple #2
0
 private function getData()
 {
     $cache = 'customer.newsletterbasic.' . json_encode($this->request->post);
     $data = Sumo\Cache::find($cache);
     if (!is_array($data) || !count($data)) {
         $data = array();
         $advanced = !empty($this->request->post['filter']) ? 1 : 0;
         $sql = "SELECT c.customer_id, c.firstname, c.lastname, c.email, c.gender, c.birthdate, a.country_id, c.newsletter, c.customer_group_id FROM PREFIX_customer AS c LEFT JOIN PREFIX_address AS a ON c.address_id = a.address_id WHERE status = 1";
         if ($advanced) {
             // Add filters
             if (empty($this->request->post['mail_type'])) {
                 $sql .= " AND newsletter = 1";
             }
             if (!empty($this->request->post['country'])) {
                 $sql .= " AND country_id = " . (int) $this->request->post['country'];
             }
             if (!empty($this->request->post['gender']) && $this->request->post['gender'] != 'b' && in_array($this->request->post['gender'], array('m', 'f'))) {
                 $sql .= " AND gender = '" . $this->request->post['gender'] . "'";
             }
             if (!empty($this->request->post['age'])) {
                 $check = explode('-', $this->request->post['age']);
                 if (count($check) == 2) {
                     $sql .= " AND (birthdate <= '" . date('Y-m-d', strtotime((int) $check[0] . ' years ago')) . "' AND birthdate >= '" . date('Y-m-d', strtotime((int) $check[1] . ' years ago')) . "')";
                 } else {
                     $sql .= " AND birthdate <= '" . date('Y-m-d', strtotime('55 years ago')) . "'";
                 }
                 $sql .= " OR birthdate = '0000-00-00'";
             }
         } else {
             switch ($this->request->post['to']) {
                 case 'newsletter':
                     $sql .= " AND newsletter = 1";
                     break;
                 case 'customer_group':
                     $sql .= " AND customer_group_id = " . (int) $this->request->post['customer_group_id'];
                     break;
                 default:
                     break;
             }
         }
         if (isset($this->request->post['start']) && isset($this->request->post['limit'])) {
             $sql .= ' LIMIT ' . (int) $this->request->post['start'] . ', ' . (int) $this->request->post['limit'];
         }
         $data = Sumo\Database::fetchAll($sql);
         Sumo\Cache::set($cache, $data);
     }
     return $data;
 }
Exemple #3
0
 public function getCategories($active = '')
 {
     $cache = 'wss_category';
     $data = Sumo\Cache::find($cache);
     if (is_array($data) && count($data)) {
         return $data;
     }
     $return = array();
     $categories = $this->fetchAll("SELECT c.category_id, c.image, c.parent_id, c.sort_order, cd.name, cd.title, cd.description, cd.meta_description, cd.meta_keyword\n            FROM PREFIX_category AS c\n            LEFT JOIN PREFIX_category_description AS cd\n                ON cd.category_id = c.category_id\n            LEFT JOIN PREFIX_category_to_store AS cts\n                ON cts.category_id = c.category_id\n            WHERE cts.store_id = :store\n                AND cd.language_id = :language\n                AND status = 1\n            ORDER BY c.parent_id, c.sort_order", array('store' => $this->config->get('store_id'), 'language' => $this->config->get('language_id')));
     // First level, head categories
     foreach ($categories as $id => $list) {
         if ($active == $list['category_id']) {
             //$list['active'] = true;
         }
         if ($list['parent_id'] == 0) {
             $list['href'] = $this->url->link('product/category', 'path=' . $list['category_id']);
             $return[$list['category_id']] = $list;
             unset($categories[$id]);
         }
     }
     // Second level, subcategories
     foreach ($categories as $id => $list) {
         if (isset($return[$list['parent_id']])) {
             $list['href'] = $this->url->link('product/category', 'path=' . $list['parent_id'] . '_' . $list['category_id']);
             $return[$list['parent_id']]['children'][$list['category_id']] = $list;
             unset($categories[$id]);
         }
     }
     // Third level, sub-subcategories
     foreach ($categories as $id => $list) {
         foreach ($return as $key => $test) {
             if (!isset($test['children'])) {
                 continue;
             }
             if (isset($test['children'][$list['parent_id']])) {
                 $list['href'] = $this->url->link('product/category', 'path=' . $key . '_' . $list['parent_id'] . '_' . $list['category_id']);
                 $return[$key]['children'][$list['parent_id']]['children'][$list['category_id']] = $list;
                 unset($categories[$id]);
             }
         }
     }
     // Fourth level, sub-sub-subcategories
     foreach ($categories as $id => $list) {
         foreach ($return as $head => $main) {
             if (!isset($main['children'])) {
                 continue;
             }
             foreach ($main['children'] as $mid => $kids) {
                 if ($kids['category_id'] == $list['parent_id']) {
                     $list['href'] = $this->url->link('product/category', 'path=' . $head . '_' . $mid . '_' . $list['parent_id'] . '_' . $list['category_id']);
                     $return[$head]['children'][$mid]['children'][$list['category_id']] = $list;
                     continue;
                 }
                 if (!isset($kids['children'])) {
                     continue;
                 }
                 foreach ($kids['children'] as $id => $kid) {
                     if ($kid['category_id'] == $list['parent_id']) {
                         $list['href'] = $this->url->link('product/category', 'path=' . $head . '_' . $mid . '_' . $list['parent_id'] . '_' . $list['category_id']);
                         $return[$head]['children'][$mid]['children'][$id]['children'][$list['category_id']] = $list;
                         continue;
                     }
                 }
             }
         }
     }
     Sumo\Cache::set($cache, $return);
     return $return;
 }
Exemple #4
0
// Language, CLEANUP REQUIRED!!!
$languages = array();
foreach (Sumo\Database::fetchAll("SELECT * FROM PREFIX_language ORDER BY language_id") as $list) {
    $languages[$list['language_id']] = $list;
}
Sumo\Language::setup($languages[$config->get('language_id')]);
$lang = $languages[$config->get('language_id')];
setlocale(LC_TIME, '');
$locale = setlocale(LC_TIME, $lang['locale']);
$config->set('locale', $lang['locale']);
Sumo\Logger::info('Locale: ' . ($locale ? 'set' : 'failed'));
Sumo\Logger::info('Language created');
// Formatter
Sumo\Formatter::setup($config);
// Cache
Sumo\Cache::setStore('admin');
// Mail
Sumo\Mail::setup($config);
Sumo\Mailer::setup($config);
// Url
$url = new Url($store['base_https'] . $config->get('admin_directory') . '/', $store['base_https'] . $config->get('admin_directory') . '/');
$registry->set('url', $url);
Sumo\Logger::info('URL created');
// Request
if (empty($_GET['route']) && !empty($_GET['_route_'])) {
    $_GET['route'] = str_replace($config->get('admin_directory') . '/', '', $_GET['_route_']);
}
$request = new Request();
$registry->set('request', $request);
Sumo\Logger::info('Request created');
// Response
Exemple #5
0
 public function getProduct($id)
 {
     $cache = 'wsp_pitem_product_category_' . $id;
     $result = Sumo\Cache::find($cache);
     if (is_array($result) && !empty($result)) {
         return $result;
     }
     if ($this->customer->isLogged()) {
         $customer_group_id = $this->customer->getCustomerGroupId();
     } else {
         $customer_group_id = $this->config->get('customer_group_id');
     }
     $product = $this->query("SELECT DISTINCT *,\n                pd.name AS name,\n                p.image,\n                m.name AS manufacturer,\n                ptc.category_id,\n                (\n                    SELECT price\n                    FROM PREFIX_product_discount pd2\n                    WHERE pd2.product_id = p.product_id\n                        AND pd2.customer_group_id = " . (int) $customer_group_id . "\n                        AND pd2.quantity = '1'\n                        AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW())\n                        AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW()))\n                    ORDER BY pd2.priority ASC, pd2.price ASC\n                    LIMIT 1\n                ) AS discount,\n                (\n                    SELECT price\n                    FROM PREFIX_product_special ps\n                    WHERE ps.product_id = p.product_id\n                        AND ps.customer_group_id = " . (int) $customer_group_id . "\n                        AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW())\n                        AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW()))\n                    ORDER BY ps.priority ASC, ps.price ASC\n                    LIMIT 1\n                ) AS special,\n                (\n                    SELECT ss.name\n                    FROM PREFIX_stock_status ss\n                    WHERE ss.stock_status_id = p.stock_status_id\n                        AND ss.language_id = " . (int) $this->config->get('language_id') . "\n                ) AS stock_status,\n                (\n                    SELECT wcd.unit\n                    FROM PREFIX_weight_class_description wcd\n                    WHERE p.weight_class_id = wcd.weight_class_id\n                        AND wcd.language_id = " . (int) $this->config->get('language_id') . "\n                ) AS weight_class,\n                (\n                    SELECT lcd.unit\n                    FROM PREFIX_length_class_description lcd\n                    WHERE p.length_class_id = lcd.length_class_id\n                        AND lcd.language_id = " . (int) $this->config->get('language_id') . "\n                ) AS length_class,\n                (\n                    SELECT AVG(rating) AS total\n                    FROM PREFIX_review r1\n                    WHERE r1.product_id = p.product_id\n                        AND r1.status = '1'\n                    GROUP BY r1.product_id\n                ) AS rating,\n                (\n                    SELECT COUNT(*) AS total\n                    FROM PREFIX_review r2\n                    WHERE r2.product_id = p.product_id\n                        AND r2.status = '1'\n                    GROUP BY r2.product_id\n                ) AS reviews,\n                p.sort_order\n            FROM PREFIX_product p\n            LEFT JOIN PREFIX_product_description pd\n                ON (p.product_id = pd.product_id)\n            LEFT JOIN PREFIX_product_to_store p2s\n                ON (p.product_id = p2s.product_id)\n            LEFT JOIN PREFIX_manufacturer m\n                ON (p.manufacturer_id = m.manufacturer_id)\n            LEFT JOIN PREFIX_product_to_category ptc\n                ON (p.product_id = ptc.product_id)\n            LEFT JOIN PREFIX_category AS c\n                ON (c.category_id = ptc.category_id)\n            WHERE p.product_id = " . (int) $id . "\n                AND pd.language_id = " . (int) $this->config->get('language_id') . "\n                AND p.status = 1\n                AND c.status = 1\n                AND p2s.store_id = " . (int) $this->config->get('store_id'))->fetch();
     if (!empty($product)) {
         if ($product['discount']) {
             //$data['price'] = $data['discount'];
         }
         $product['images'][] = $product['image'];
         $images = $this->fetchAll("SELECT image FROM PREFIX_product_image WHERE product_id = :id ORDER BY sort_order ASC", array('id' => $id));
         if (is_array($images) && count($images)) {
             foreach ($images as $list) {
                 $product['images'][] = $list['image'];
             }
         }
         Sumo\Cache::set($cache, $product);
         return $product;
     }
     return false;
 }
 public function getTotalProductsPrice($filter = array())
 {
     $cache = 'inventory.product.price.' . md5(json_encode($filter));
     $data = Sumo\Cache::find($cache);
     if ($data) {
         return $data;
     }
     $sqlFilter = $this->filterToSQL($filter);
     if (!empty($sqlFilter['sql'])) {
         $sqlFilter['sql'] = ' AND ' . $sqlFilter['sql'];
     }
     $sqlFilter['sqlValues']['languageID'] = (int) $this->config->get('language_id');
     $total = 0;
     foreach ($this->fetchAll("SELECT p.product_id, quantity, price, cost_price, stock_id, tax_percentage\n            FROM PREFIX_product AS p\n            LEFT JOIN PREFIX_product_description pd\n                ON p.product_id = pd.product_id\n            WHERE pd.language_id = :languageID AND status = 1 " . $sqlFilter['sql'], $sqlFilter['sqlValues']) as $item) {
         // Check for options
         $options = $this->fetchAll("SELECT option_id FROM PREFIX_product_option WHERE product_id = :id", array('id' => $item['product_id']));
         if (count($options)) {
             foreach ($options as $option) {
                 foreach ($this->fetchAll("SELECT price, price_prefix, quantity FROM PREFIX_product_option_value WHERE active = 1 AND option_id = :id", array('id' => $option['option_id'])) as $value) {
                     if ($value['price_prefix'] == '-') {
                         $price = $item['price'] - $value['price'];
                     } else {
                         $price = $item['price'] + $value['price'];
                     }
                     $total += $price * $value['quantity'];
                 }
             }
         } else {
             if ($item['stock_id'] == $item['product_id']) {
                 $total += $item['price'] * $item['quantity'];
             } else {
                 $linked = $this->query("SELECT quantity FROM PREFIX_product WHERE product_id = :id", array('id' => $item['stock_id']))->fetch();
                 $total += $item['price'] * $linked['quantity'];
             }
         }
     }
     Sumo\Cache::set($cache, $total);
     return $total;
 }
Exemple #7
0
 public function getManufacturers()
 {
     $manufacturer_data = Sumo\Cache::find('manufacturer.' . (int) $this->config->get('store_id'));
     if (!$manufacturer_data) {
         $manufacturer_data = $this->fetchAll("SELECT * FROM PREFIX_manufacturer m LEFT JOIN PREFIX_manufacturer_to_store m2s ON (m.manufacturer_id = m2s.manufacturer_id) WHERE m2s.store_id = :store ORDER BY RAND()", array('store' => $this->config->get('store_id')));
         Sumo\Cache::set('manufacturer.' . (int) $this->config->get('store_id'), $manufacturer_data);
     }
     return $manufacturer_data;
 }