示例#1
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->loadModel('catalog/product');
     $this->loadModel('catalog/review');
     $this->loadModel('tool/seo_url');
     $this->loadModel('tool/image');
     $promoton = new APromotion();
     $this->data['button_add_to_cart'] = $this->language->get('button_add_to_cart');
     $this->data['products'] = array();
     $results = $promoton->getProductSpecials('pd.name', 'ASC', 0, $this->config->get('config_special_limit'));
     $resource = new AResource('image');
     foreach ($results as $result) {
         $thumbnail = $resource->getMainThumb('products', $result['product_id'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'), true);
         if ($this->config->get('enable_reviews')) {
             $rating = $this->model_catalog_review->getAverageRating($result['product_id']);
         } else {
             $rating = false;
         }
         $special = FALSE;
         $discount = $promoton->getProductDiscount($result['product_id']);
         if ($discount) {
             $price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
         } else {
             $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
             $special = $promoton->getProductSpecial($result['product_id']);
             if ($special) {
                 $special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
             }
         }
         $options = $this->model_catalog_product->getProductOptions($result['product_id']);
         if ($options) {
             $add = $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode');
         } else {
             if ($this->config->get('config_cart_ajax')) {
                 $add = '#';
             } else {
                 $add = $this->html->getSecureURL('checkout/cart', '&product_id=' . $result['product_id'], '&encode');
             }
         }
         $this->data['products'][] = array('product_id' => $result['product_id'], 'name' => $result['name'], 'model' => $result['model'], 'rating' => $rating, 'stars' => sprintf($this->language->get('text_stars'), $rating), 'price' => $price, 'call_to_order' => $result['call_to_order'], 'options' => $options, 'special' => $special, 'thumb' => $thumbnail, 'href' => $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode'), 'add' => $add);
     }
     if ($this->config->get('config_customer_price')) {
         $this->data['display_price'] = TRUE;
     } elseif ($this->customer->isLogged()) {
         $this->data['display_price'] = TRUE;
     } else {
         $this->data['display_price'] = FALSE;
     }
     $this->data['review_status'] = $this->config->get('enable_reviews');
     // framed needs to show frames for generic block.
     //If tpl used by listing block framed was set by listing block settings
     $this->data['block_framed'] = true;
     $this->view->batchAssign($this->data);
     $this->processTemplate();
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
示例#2
0
 public function getTotal(&$total_data, &$total, &$taxes)
 {
     if (isset($this->session->data['coupon']) && $this->config->get('coupon_status')) {
         $promotion = new APromotion();
         $coupon = $promotion->getCouponData($this->session->data['coupon']);
         if ($coupon) {
             $discount_total = 0;
             if (!$coupon['product']) {
                 $coupon_total = $this->cart->getSubTotal();
             } else {
                 $coupon_total = 0;
                 foreach ($this->cart->getProducts() as $product) {
                     if (in_array($product['product_id'], $coupon['product'])) {
                         $coupon_total += $product['total'];
                     }
                 }
             }
             if ($coupon['type'] == 'F') {
                 $coupon['discount'] = min($coupon['discount'], $coupon_total);
             }
             foreach ($this->cart->getProducts() as $product) {
                 $discount = 0;
                 if (!$coupon['product']) {
                     $status = TRUE;
                 } else {
                     if (in_array($product['product_id'], $coupon['product'])) {
                         $status = TRUE;
                     } else {
                         $status = FALSE;
                     }
                 }
                 if ($status) {
                     if ($coupon['type'] == 'F') {
                         $discount = $coupon['discount'] * ($product['total'] / $coupon_total);
                     } elseif ($coupon['type'] == 'P') {
                         $discount = $product['total'] / 100 * $coupon['discount'];
                     }
                     if ($product['tax_class_id']) {
                         $taxes[$product['tax_class_id']]['total'] -= $discount;
                         $taxes[$product['tax_class_id']]['tax'] -= $this->tax->calcTotalTaxAmount($product['total'], $product['tax_class_id']) - $this->tax->calcTotalTaxAmount($product['total'] - $discount, $product['tax_class_id']);
                     }
                 }
                 $discount_total += $discount;
             }
             $ship_data = $this->session->data['shipping_method'];
             if ($coupon['shipping'] && isset($ship_data)) {
                 if (isset($ship_data['tax_class_id']) && $ship_data['tax_class_id']) {
                     $taxes[$ship_data['tax_class_id']]['total'] -= $ship_data['cost'];
                     $taxes[$ship_data['tax_class_id']]['tax'] -= $this->tax->calcTotalTaxAmount($ship_data['cost'], $ship_data['tax_class_id']);
                 }
                 $discount_total += $ship_data['cost'];
             }
             $total_data[] = array('id' => 'coupon', 'title' => $coupon['name'] . ':', 'text' => '-' . $this->currency->format($discount_total), 'value' => -$discount_total, 'sort_order' => $this->config->get('coupon_sort_order'), 'total_type' => $this->config->get('coupon_total_type'));
             $total -= $discount_total;
         }
     }
 }
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('catalog/product');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->loadModel('catalog/product');
     $promoton = new APromotion();
     if (isset($this->request->get['product_id']) && $this->request->server['REQUEST_METHOD'] != 'POST') {
         $product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']);
         if (!$product_info) {
             $this->session->data['warning'] = $this->language->get('error_product_not_found');
             $this->redirect($this->html->getSecureURL('catalog/product'));
         }
     }
     $this->view->assign('error_warning', $this->error['warning']);
     $this->view->assign('success', $this->session->data['success']);
     if (isset($this->session->data['success'])) {
         unset($this->session->data['success']);
     }
     $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     $this->loadModel('sale/customer_group');
     $results = $this->model_sale_customer_group->getCustomerGroups();
     $this->data['customer_groups'] = array();
     foreach ($results as $r) {
         $this->data['customer_groups'][$r['customer_group_id']] = $r['name'];
     }
     $this->data['product_discounts'] = $promoton->getProductDiscounts($this->request->get['product_id']);
     $this->data['delete'] = $this->html->getSecureURL('catalog/product_discount/delete', '&product_id=' . $this->request->get['product_id'] . '&product_discount_id=%ID%');
     $this->data['update'] = $this->html->getSecureURL('catalog/product_discount/update', '&product_id=' . $this->request->get['product_id'] . '&product_discount_id=%ID%');
     $this->data['insert'] = $this->html->getSecureURL('catalog/product_discount/insert', '&product_id=' . $this->request->get['product_id']);
     $this->data['link_general'] = $this->html->getSecureURL('catalog/product/update', '&product_id=' . $this->request->get['product_id']);
     $this->data['link_links'] = $this->html->getSecureURL('catalog/product_links', '&product_id=' . $this->request->get['product_id']);
     $this->data['link_options'] = $this->html->getSecureURL('catalog/product_options', '&product_id=' . $this->request->get['product_id']);
     $this->data['link_discount'] = $this->html->getSecureURL('catalog/product_discount', '&product_id=' . $this->request->get['product_id']);
     $this->data['link_special'] = $this->html->getSecureURL('catalog/product_special', '&product_id=' . $this->request->get['product_id']);
     $this->data['link_images'] = $this->html->getSecureURL('catalog/product_images', '&product_id=' . $this->request->get['product_id']);
     $this->data['product_description'] = $this->model_catalog_product->getProductDescriptions($this->request->get['product_id']);
     $this->data['form_title'] = $this->language->get('text_edit') . ' ' . $this->data['product_description'][$this->session->data['content_language_id']]['name'];
     $this->data['button_remove'] = $this->html->buildButton(array('text' => $this->language->get('button_remove'), 'style' => 'button2'));
     $this->data['button_edit'] = $this->html->buildButton(array('text' => $this->language->get('button_edit'), 'style' => 'button2'));
     $this->data['button_add_discount'] = $this->html->buildButton(array('text' => $this->language->get('button_add_discount'), 'style' => 'button1'));
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/catalog/product_discount_list.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
示例#4
0
 public function category()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadModel('catalog/product');
     $promoton = new APromotion($this->request->get['customer_group_id']);
     if (isset($this->request->get['category_id'])) {
         $category_id = $this->request->get['category_id'];
     } else {
         $category_id = 0;
     }
     $product_data = array();
     $results = $this->model_catalog_product->getProductsByCategoryId($category_id);
     foreach ($results as $result) {
         $discount = $promoton->getProductDiscount($result['product_id']);
         if ($discount) {
             $price = $discount;
         } else {
             $price = $result['price'];
             $special = $promoton->getProductSpecial($result['product_id']);
             if ($special) {
                 $price = $special;
             }
         }
         if (!empty($this->request->get['currency']) && !empty($this->request->get['value'])) {
             $price = $this->currency->format((double) $price, $this->request->get['currency'], $this->request->get['value']);
         } else {
             $price = $this->currency->format((double) $price);
         }
         $product_data[] = array('product_id' => $result['product_id'], 'name' => $result['name'], 'model' => $result['model'], 'price' => $price);
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->load->library('json');
     $this->response->addJSONHeader();
     $this->response->setOutput(AJson::encode($product_data));
 }
示例#5
0
 private function _validateCoupon()
 {
     $this->loadLanguage('checkout/payment');
     $promotion = new APromotion();
     $coupon = $promotion->getCouponData($this->request->post['coupon']);
     if (!$coupon) {
         $this->error['warning'] = $this->language->get('error_coupon');
     }
     $this->extensions->hk_ValidateData($this);
     if (!$this->error) {
         return true;
     } else {
         return false;
     }
 }
 public function onControllerPagesCheckoutGuestStep2_InitData()
 {
     $error = false;
     $that = $this->baseObject;
     if (isset($that->request->post['shipping_method'])) {
         $shipping = explode('.', $that->request->post['shipping_method']);
         $that->session->data['shipping_method'] = $that->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]];
     }
     if ($that->request->get['mode'] == 'edit') {
         unset($that->session->data['pp_express_checkout']);
     }
     // if coupon code was submited
     if (has_value($that->request->post['coupon'])) {
         $promotion = new APromotion();
         $coupon = $promotion->getCouponData($that->request->post['coupon']);
         // rebuild order data if coupon applied
         $order = new AOrder(Registry::getInstance());
         $this->data = $order->buildOrderData($that->session->data);
         $order->saveOrder();
         if ($coupon) {
             $that->session->data['coupon'] = $that->request->post['coupon'];
         } else {
             $error = true;
         }
     }
     if (!$error && $that->request->server['REQUEST_METHOD'] == 'POST' && ($that->request->post['payment_method'] == 'default_pp_express' || $that->session->data['payment_method']['id'] == 'default_pp_express')) {
         if (!has_value($that->session->data['pp_express_checkout']['token']) || !has_value($that->session->data['pp_express_checkout']['PayerID'])) {
             // rebuild order data if coupon applied
             $order = new AOrder(Registry::getInstance());
             $this->data = $order->buildOrderData($that->session->data);
             $order->saveOrder();
             $redirect_url = $that->html->getSecureURL('checkout/guest_step_3');
             header('Location: ' . $that->html->getSecureURL('r/extension/default_pp_express/set_pp', '&to_confirm=1&redirect_to=' . urlencode($redirect_url)));
             exit;
         }
     }
 }
 private function _validateCoupon($coupon)
 {
     $promotion = new APromotion();
     $coupon = $promotion->getCouponData($coupon);
     if (!$coupon) {
         $this->error['warning'] = $this->language->get('error_coupon');
     }
     if (!$this->error) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
示例#8
0
 /**
  * @param array $indata : Session data array
  * @return array 
  * NOTE: method to create an order based on provided data array. 
  */
 public function buildOrderData($indata)
 {
     $order_info = array();
     if (empty($indata)) {
         return array();
     }
     $total_data = array();
     $total = 0;
     $taxes = $this->cart->getTaxes();
     $this->load->model('checkout/extension');
     $sort_order = array();
     $results = $this->model_checkout_extension->getExtensions('total');
     foreach ($results as $key => $value) {
         $sort_order[$key] = $this->config->get($value['key'] . '_sort_order');
     }
     array_multisort($sort_order, SORT_ASC, $results);
     foreach ($results as $result) {
         $this->load->model('total/' . $result['key']);
         $this->{'model_total_' . $result['key']}->getTotal($total_data, $total, $taxes, $indata);
     }
     $sort_order = array();
     foreach ($total_data as $key => $value) {
         $sort_order[$key] = $value['sort_order'];
     }
     array_multisort($sort_order, SORT_ASC, $total_data);
     $order_info['store_id'] = $this->config->get('config_store_id');
     $order_info['store_name'] = $this->config->get('store_name');
     $order_info['store_url'] = $this->config->get('config_url');
     //prepare data with customer details.
     if ($this->customer->getId()) {
         $order_info['customer_id'] = $this->customer->getId();
         $order_info['customer_group_id'] = $this->customer->getCustomerGroupId();
         $order_info['firstname'] = $this->customer->getFirstName();
         $order_info['lastname'] = $this->customer->getLastName();
         $order_info['email'] = $this->customer->getEmail();
         $order_info['telephone'] = $this->customer->getTelephone();
         $order_info['fax'] = $this->customer->getFax();
         $this->load->model('account/address');
         if ($this->cart->hasShipping()) {
             $ship_address_id = $indata['shipping_address_id'];
             $ship_address = $this->model_account_address->getAddress($ship_address_id);
             $order_info['shipping_firstname'] = $ship_address['firstname'];
             $order_info['shipping_lastname'] = $ship_address['lastname'];
             $order_info['shipping_company'] = $ship_address['company'];
             $order_info['shipping_address_1'] = $ship_address['address_1'];
             $order_info['shipping_address_2'] = $ship_address['address_2'];
             $order_info['shipping_city'] = $ship_address['city'];
             $order_info['shipping_postcode'] = $ship_address['postcode'];
             $order_info['shipping_zone'] = $ship_address['zone'];
             $order_info['shipping_zone_id'] = $ship_address['zone_id'];
             $order_info['shipping_country'] = $ship_address['country'];
             $order_info['shipping_country_id'] = $ship_address['country_id'];
             $order_info['shipping_address_format'] = $ship_address['address_format'];
         } else {
             $order_info['shipping_firstname'] = '';
             $order_info['shipping_lastname'] = '';
             $order_info['shipping_company'] = '';
             $order_info['shipping_address_1'] = '';
             $order_info['shipping_address_2'] = '';
             $order_info['shipping_city'] = '';
             $order_info['shipping_postcode'] = '';
             $order_info['shipping_zone'] = '';
             $order_info['shipping_zone_id'] = '';
             $order_info['shipping_country'] = '';
             $order_info['shipping_country_id'] = '';
             $order_info['shipping_address_format'] = '';
             $order_info['shipping_method'] = '';
         }
         $pay_address_id = $indata['payment_address_id'];
         $pay_address = $this->model_account_address->getAddress($pay_address_id);
         $order_info['payment_firstname'] = $pay_address['firstname'];
         $order_info['payment_lastname'] = $pay_address['lastname'];
         $order_info['payment_company'] = $pay_address['company'];
         $order_info['payment_address_1'] = $pay_address['address_1'];
         $order_info['payment_address_2'] = $pay_address['address_2'];
         $order_info['payment_city'] = $pay_address['city'];
         $order_info['payment_postcode'] = $pay_address['postcode'];
         $order_info['payment_zone'] = $pay_address['zone'];
         $order_info['payment_zone_id'] = $pay_address['zone_id'];
         $order_info['payment_country'] = $pay_address['country'];
         $order_info['payment_country_id'] = $pay_address['country_id'];
         $order_info['payment_address_format'] = $pay_address['address_format'];
     } else {
         if (isset($indata['guest'])) {
             //this is a guest order
             $order_info['customer_id'] = 0;
             $order_info['customer_group_id'] = $this->config->get('config_customer_group_id');
             $order_info['firstname'] = $indata['guest']['firstname'];
             $order_info['lastname'] = $indata['guest']['lastname'];
             $order_info['email'] = $indata['guest']['email'];
             $order_info['telephone'] = $indata['guest']['telephone'];
             $order_info['fax'] = $indata['guest']['fax'];
             if ($this->cart->hasShipping()) {
                 if (isset($indata['guest']['shipping'])) {
                     $order_info['shipping_firstname'] = $indata['guest']['shipping']['firstname'];
                     $order_info['shipping_lastname'] = $indata['guest']['shipping']['lastname'];
                     $order_info['shipping_company'] = $indata['guest']['shipping']['company'];
                     $order_info['shipping_address_1'] = $indata['guest']['shipping']['address_1'];
                     $order_info['shipping_address_2'] = $indata['guest']['shipping']['address_2'];
                     $order_info['shipping_city'] = $indata['guest']['shipping']['city'];
                     $order_info['shipping_postcode'] = $indata['guest']['shipping']['postcode'];
                     $order_info['shipping_zone'] = $indata['guest']['shipping']['zone'];
                     $order_info['shipping_zone_id'] = $indata['guest']['shipping']['zone_id'];
                     $order_info['shipping_country'] = $indata['guest']['shipping']['country'];
                     $order_info['shipping_country_id'] = $indata['guest']['shipping']['country_id'];
                     $order_info['shipping_address_format'] = $indata['guest']['shipping']['address_format'];
                 } else {
                     $order_info['shipping_firstname'] = $indata['guest']['firstname'];
                     $order_info['shipping_lastname'] = $indata['guest']['lastname'];
                     $order_info['shipping_company'] = $indata['guest']['company'];
                     $order_info['shipping_address_1'] = $indata['guest']['address_1'];
                     $order_info['shipping_address_2'] = $indata['guest']['address_2'];
                     $order_info['shipping_city'] = $indata['guest']['city'];
                     $order_info['shipping_postcode'] = $indata['guest']['postcode'];
                     $order_info['shipping_zone'] = $indata['guest']['zone'];
                     $order_info['shipping_zone_id'] = $indata['guest']['zone_id'];
                     $order_info['shipping_country'] = $indata['guest']['country'];
                     $order_info['shipping_country_id'] = $indata['guest']['country_id'];
                     $order_info['shipping_address_format'] = $indata['guest']['address_format'];
                 }
             } else {
                 $order_info['shipping_firstname'] = '';
                 $order_info['shipping_lastname'] = '';
                 $order_info['shipping_company'] = '';
                 $order_info['shipping_address_1'] = '';
                 $order_info['shipping_address_2'] = '';
                 $order_info['shipping_city'] = '';
                 $order_info['shipping_postcode'] = '';
                 $order_info['shipping_zone'] = '';
                 $order_info['shipping_zone_id'] = '';
                 $order_info['shipping_country'] = '';
                 $order_info['shipping_country_id'] = '';
                 $order_info['shipping_address_format'] = '';
                 $order_info['shipping_method'] = '';
             }
             $order_info['payment_firstname'] = $indata['guest']['firstname'];
             $order_info['payment_lastname'] = $indata['guest']['lastname'];
             $order_info['payment_company'] = $indata['guest']['company'];
             $order_info['payment_address_1'] = $indata['guest']['address_1'];
             $order_info['payment_address_2'] = $indata['guest']['address_2'];
             $order_info['payment_city'] = $indata['guest']['city'];
             $order_info['payment_postcode'] = $indata['guest']['postcode'];
             $order_info['payment_zone'] = $indata['guest']['zone'];
             $order_info['payment_zone_id'] = $indata['guest']['zone_id'];
             $order_info['payment_country'] = $indata['guest']['country'];
             $order_info['payment_country_id'] = $indata['guest']['country_id'];
             $order_info['payment_address_format'] = $indata['guest']['address_format'];
         } else {
             return array();
         }
     }
     if (isset($indata['shipping_method']['title'])) {
         $order_info['shipping_method'] = $indata['shipping_method']['title'];
         $order_info['shipping_method_key'] = $indata['shipping_method']['id'];
         // note - id by mask method_txt_id.method_option_id. for ex. default_weight.default_weight_1
     } else {
         $order_info['shipping_method'] = '';
         $order_info['shipping_method_key'] = '';
     }
     if (isset($indata['payment_method']['title'])) {
         $order_info['payment_method'] = $indata['payment_method']['title'];
         preg_match('/^([^.]+)/', $indata['payment_method']['id'], $matches);
         $order_info['payment_method_key'] = $matches[1];
     } else {
         $order_info['payment_method'] = '';
     }
     $product_data = array();
     foreach ($this->cart->getProducts() as $product) {
         $product_data[] = array('product_id' => $product['product_id'], 'name' => $product['name'], 'model' => $product['model'], 'option' => $product['option'], 'download' => $product['download'], 'quantity' => $product['quantity'], 'price' => $product['price'], 'total' => $product['total'], 'tax' => $this->tax->calcTotalTaxAmount($product['total'], $product['tax_class_id']), 'stock' => $product['stock'], 'sku' => $product['sku']);
     }
     $order_info['products'] = $product_data;
     $order_info['totals'] = $total_data;
     $order_info['comment'] = $indata['comment'];
     $order_info['total'] = $total;
     $order_info['language_id'] = $this->config->get('storefront_language_id');
     $order_info['currency_id'] = $this->currency->getId();
     $order_info['currency'] = $this->currency->getCode();
     $order_info['value'] = $this->currency->getValue($this->currency->getCode());
     if (isset($indata['coupon'])) {
         $promotion = new APromotion();
         $coupon = $promotion->getCouponData($indata['coupon']);
         if ($coupon) {
             $order_info['coupon_id'] = $coupon['coupon_id'];
         } else {
             $order_info['coupon_id'] = 0;
         }
     } else {
         $order_info['coupon_id'] = 0;
     }
     $order_info['ip'] = $this->request->server['REMOTE_ADDR'];
     $this->order_data = $order_info;
     return $this->order_data;
 }
示例#9
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->setTitle($this->language->get('heading_title'));
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $url = '';
     if (isset($this->request->get['keyword'])) {
         $url .= '&keyword=' . $this->request->get['keyword'];
     }
     if (isset($this->request->get['category_id'])) {
         $url .= '&category_id=' . $this->request->get['category_id'];
     }
     if (isset($this->request->get['description'])) {
         $url .= '&description=' . $this->request->get['description'];
     }
     if (isset($this->request->get['model'])) {
         $url .= '&model=' . $this->request->get['model'];
     }
     if (isset($this->request->get['sort'])) {
         $url .= '&sort=' . $this->request->get['sort'];
     }
     if (isset($this->request->get['order'])) {
         $url .= '&order=' . $this->request->get['order'];
     }
     if (isset($this->request->get['page'])) {
         $url .= '&page=' . $this->request->get['page'];
     }
     if (isset($this->request->get['limit'])) {
         $url .= '&limit=' . $this->request->get['limit'];
     }
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('product/search', $url), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator')));
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     if (isset($this->request->get['sort'])) {
         list($sort, $order) = explode("-", $this->request->get['sort']);
     } else {
         list($sort, $order) = explode("-", $this->config->get('config_product_default_sort_order'));
         if ($sort == 'name') {
             $sort = 'pd.' . $sort;
         } elseif (in_array($sort, array('sort_order', 'price'))) {
             $sort = 'p.' . $sort;
         }
     }
     $this->data['keyword'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'keyword', 'value' => $this->request->get['keyword']));
     $this->data['keyword'] = $this->data['keyword']->getHtml();
     $this->loadModel('catalog/category');
     $categories = $this->_getCategories(0);
     $options = array(0 => $this->language->get('text_category'));
     if ($categories) {
         foreach ($categories as $item) {
             $options[$item['category_id']] = $item['name'];
         }
     }
     $this->data['category'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'category_id', 'options' => $options, 'value' => $this->request->get['category_id']));
     $this->data['description'] = HtmlElementFactory::create(array('type' => 'checkbox', 'id' => 'description', 'name' => 'description', 'checked' => (int) $this->request->get['description'], 'value' => 1, 'label_text' => $this->language->get('entry_description')));
     $this->data['model'] = HtmlElementFactory::create(array('type' => 'checkbox', 'id' => 'model', 'name' => 'model', 'checked' => (bool) $this->request->get['model'], 'value' => 1, 'label_text' => $this->language->get('entry_model')));
     $this->data['submit'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'search_button', 'text' => $this->language->get('button_search'), 'icon' => 'icon-search', 'style' => 'button'));
     if (isset($this->request->get['keyword'])) {
         $this->loadModel('catalog/product');
         $promoton = new APromotion();
         if (isset($this->request->get['category_id'])) {
             $category_id = explode(',', $this->request->get['category_id']);
             end($category_id);
             $category_id = current($category_id);
         } else {
             $category_id = '';
         }
         $product_total = $this->model_catalog_product->getTotalProductsByKeyword($this->request->get['keyword'], $category_id, isset($this->request->get['description']) ? $this->request->get['description'] : '', isset($this->request->get['model']) ? $this->request->get['model'] : '');
         if ($product_total) {
             $url = '';
             if (isset($this->request->get['category_id'])) {
                 $url .= '&category_id=' . $this->request->get['category_id'];
             }
             if (isset($this->request->get['description'])) {
                 $url .= '&description=' . $this->request->get['description'];
             }
             if (isset($this->request->get['model'])) {
                 $url .= '&model=' . $this->request->get['model'];
             }
             $limit = $this->config->get('config_catalog_limit');
             if (isset($this->request->get['limit']) && intval($this->request->get['limit']) > 0) {
                 $limit = intval($this->request->get['limit']);
                 if ($limit > 50) {
                     $limit = 50;
                 }
             }
             $this->loadModel('catalog/review');
             $this->loadModel('tool/seo_url');
             $products = array();
             $results = $this->model_catalog_product->getProductsByKeyword($this->request->get['keyword'], $category_id, isset($this->request->get['description']) ? $this->request->get['description'] : '', isset($this->request->get['model']) ? $this->request->get['model'] : '', $sort, $order, ($page - 1) * $limit, $limit);
             //if single result, redirect to the product
             if (count($results) == 1) {
                 $this->redirect($this->html->getSEOURL('product/product', '&product_id=' . key($results), '&encode'));
             }
             $resource = new AResource('image');
             if (is_array($results) && $results) {
                 foreach ($results as $result) {
                     $thumbnail = $resource->getMainThumb('products', $result['product_id'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'), true);
                     if ($this->config->get('enable_reviews')) {
                         $rating = $this->model_catalog_review->getAverageRating($result['product_id']);
                     } else {
                         $rating = false;
                     }
                     $special = FALSE;
                     $discount = $promoton->getProductDiscount($result['product_id']);
                     if ($discount) {
                         $price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
                     } else {
                         $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
                         $special = $promoton->getProductSpecial($result['product_id']);
                         if ($special) {
                             $special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
                         }
                     }
                     $options = $this->model_catalog_product->getProductOptions($result['product_id']);
                     if ($options) {
                         $add = $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode');
                     } else {
                         if ($this->config->get('config_cart_ajax')) {
                             $add = '#';
                         } else {
                             $add = $this->html->getSecureURL('checkout/cart', '&product_id=' . $result['product_id'], '&encode');
                         }
                     }
                     $products[] = array('product_id' => $result['product_id'], 'name' => $result['name'], 'model' => $result['model'], 'rating' => $rating, 'stars' => sprintf($this->language->get('text_stars'), $rating), 'thumb' => $thumbnail, 'price' => $price, 'call_to_order' => $result['call_to_order'], 'options' => $options, 'special' => $special, 'href' => $this->html->getSEOURL('product/product', '&keyword=' . $this->request->get['keyword'] . $url . '&product_id=' . $result['product_id'], '&encode'), 'add' => $add, 'description' => html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'));
                 }
             }
             $this->data['products'] = $products;
             if ($this->config->get('config_customer_price')) {
                 $display_price = TRUE;
             } elseif ($this->customer->isLogged()) {
                 $display_price = TRUE;
             } else {
                 $display_price = FALSE;
             }
             $this->data['display_price'] = $display_price;
             $url = '';
             if (isset($this->request->get['keyword'])) {
                 $url .= '&keyword=' . $this->request->get['keyword'];
             }
             if (isset($this->request->get['category_id'])) {
                 $url .= '&category_id=' . $this->request->get['category_id'];
             }
             if (isset($this->request->get['description'])) {
                 $url .= '&description=' . $this->request->get['description'];
             }
             if (isset($this->request->get['model'])) {
                 $url .= '&model=' . $this->request->get['model'];
             }
             if (isset($this->request->get['page'])) {
                 $url .= '&page=' . $this->request->get['page'];
             }
             if (isset($this->request->get['limit'])) {
                 $url .= '&limit=' . $this->request->get['limit'];
             }
             $sorts = array();
             $sorts[] = array('text' => $this->language->get('text_default'), 'value' => 'p.sort_order-ASC', 'href' => $this->html->getURL('product/search', $url . '&sort=p.sort_order&order=ASC', '&encode'));
             $sorts[] = array('text' => $this->language->get('text_sorting_name_asc'), 'value' => 'pd.name-ASC', 'href' => $this->html->getURL('product/search', $url . '&sort=pd.name&order=ASC', '&encode'));
             $sorts[] = array('text' => $this->language->get('text_sorting_name_desc'), 'value' => 'pd.name-DESC', 'href' => $this->html->getURL('product/search', $url . '&sort=pd.name&order=DESC', '&encode'));
             $sorts[] = array('text' => $this->language->get('text_sorting_price_asc'), 'value' => 'p.price-ASC', 'href' => $this->html->getURL('product/search', $url . '&sort=p.price&order=ASC', '&encode'));
             $sorts[] = array('text' => $this->language->get('text_sorting_price_desc'), 'value' => 'p.price-DESC', 'href' => $this->html->getURL('product/search', $url . '&sort=p.price&order=DESC', '&encode'));
             $sorts[] = array('text' => $this->language->get('text_sorting_rating_desc'), 'value' => 'rating-DESC', 'href' => $this->html->getURL('product/search', $url . '&sort=rating&order=DESC', '&encode'));
             $sorts[] = array('text' => $this->language->get('text_sorting_rating_asc'), 'value' => 'rating-ASC', 'href' => $this->html->getURL('product/search', $url . '&sort=rating&order=ASC', '&encode'));
             $sorts[] = array('text' => $this->language->get('text_sorting_date_desc'), 'value' => 'date_modified-DESC', 'href' => $this->html->getSEOURL('product/search', $url . '&sort=date_modified&order=DESC', '&encode'));
             $sorts[] = array('text' => $this->language->get('text_sorting_date_asc'), 'value' => 'date_modified-ASC', 'href' => $this->html->getSEOURL('product/search', $url . '&sort=date_modified&order=ASC', '&encode'));
             $this->data['sorts'] = $sorts;
             $options = array();
             foreach ($sorts as $item) {
                 $options[$item['value']] = $item['text'];
             }
             $sorting = $this->html->buildSelectbox(array('name' => 'sort', 'options' => $options, 'value' => $sort . '-' . $order));
             $this->data['sorting'] = $sorting;
             $url = '';
             if (isset($this->request->get['keyword'])) {
                 $url .= '&keyword=' . $this->request->get['keyword'];
             }
             if (isset($this->request->get['category_id'])) {
                 $url .= '&category_id=' . $this->request->get['category_id'];
             }
             if (isset($this->request->get['description'])) {
                 $url .= '&description=' . $this->request->get['description'];
             }
             if (isset($this->request->get['model'])) {
                 $url .= '&model=' . $this->request->get['model'];
             }
             if (isset($this->request->get['sort'])) {
                 $url .= '&sort=' . $this->request->get['sort'];
             }
             if (isset($this->request->get['order'])) {
                 $url .= '&order=' . $this->request->get['order'];
             }
             if (isset($this->request->get['limit'])) {
                 $url .= '&limit=' . $this->request->get['limit'];
             }
             $this->data['pagination_bootstrap'] = HtmlElementFactory::create(array('type' => 'Pagination', 'name' => 'pagination', 'text' => $this->language->get('text_pagination'), 'text_limit' => $this->language->get('text_per_page'), 'total' => $product_total, 'page' => $page, 'limit' => $limit, 'url' => $this->html->getURL('product/search', $url . '&page={page}', '&encode'), 'style' => 'pagination'));
             $this->data['sort'] = $sort;
             $this->data['order'] = $order;
             $this->data['limit'] = $limit;
         }
     }
     $this->data['review_status'] = $this->config->get('enable_reviews');
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/product/search.tpl');
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
示例#10
0
 /**
  * Collect product information for cart based on user selections
  * Function can be used to get totals and other product information
  * (based on user selection) as it is before getting into cart or after
  * @param int $product_id
  * @param int $quantity
  * @param array $options
  * @return array
  */
 public function buildProductDetails($product_id, $quantity = 0, $options = array())
 {
     if (!has_value($product_id) || !is_numeric($product_id) || $quantity == 0) {
         return array();
     }
     $stock = TRUE;
     $sf_product_mdl = $this->load->model('catalog/product', 'storefront');
     $elements_with_options = HtmlElementFactory::getElementsWithOptions();
     $product_query = $sf_product_mdl->getProductDataForCart($product_id);
     if (count($product_query) <= 0 || $product_query['call_to_order']) {
         return array();
     }
     $option_price = 0;
     $option_data = array();
     $groups = array();
     //Process each option and value
     foreach ($options as $product_option_id => $product_option_value_id) {
         //skip empty values
         if ($product_option_value_id == '' || is_array($product_option_value_id) && !$product_option_value_id) {
             continue;
         }
         $option_query = $sf_product_mdl->getProductOption($product_id, $product_option_id);
         $element_type = $option_query['element_type'];
         if (!in_array($element_type, $elements_with_options)) {
             //This is single value element, get all values and expect only one
             $option_value_query = $sf_product_mdl->getProductOptionValues($product_id, $product_option_id);
             $option_value_query = $option_value_query[0];
             //Set value from input
             $option_value_query['name'] = $this->db->escape($options[$product_option_id]);
         } else {
             //is multivalue option type
             if (is_array($product_option_value_id)) {
                 $option_value_queries = array();
                 foreach ($product_option_value_id as $val_id) {
                     $option_value_queries[$val_id] = $sf_product_mdl->getProductOptionValue($product_id, $val_id);
                 }
             } else {
                 $option_value_query = $sf_product_mdl->getProductOptionValue($product_id, (int) $product_option_value_id);
             }
         }
         if ($option_value_query) {
             //if group option load price from parent value
             if ($option_value_query['group_id'] && !in_array($option_value_query['group_id'], $groups)) {
                 $group_value_query = $sf_product_mdl->getProductOptionValue($product_id, $option_value_query['group_id']);
                 $option_value_query['prefix'] = $group_value_query['prefix'];
                 $option_value_query['price'] = $group_value_query['price'];
                 $groups[] = $option_value_query['group_id'];
             }
             $option_data[] = array('product_option_value_id' => $option_value_query['product_option_value_id'], 'product_option_id' => $product_option_id, 'name' => $option_query['name'], 'element_type' => $element_type, 'settings' => $option_query['settings'], 'value' => $option_value_query['name'], 'prefix' => $option_value_query['prefix'], 'price' => $option_value_query['price'], 'sku' => $option_value_query['sku'], 'weight' => $option_value_query['weight'], 'weight_type' => $option_value_query['weight_type']);
             //check if need to track stock and we have it
             if ($option_value_query['subtract'] && $option_value_query['quantity'] < $quantity) {
                 $stock = FALSE;
             }
             $op_stock_trackable += $option_value_query['subtract'];
             unset($option_value_query);
         } else {
             if ($option_value_queries) {
                 foreach ($option_value_queries as $item) {
                     $option_data[] = array('product_option_value_id' => $item['product_option_value_id'], 'name' => $option_query['name'], 'value' => $item['name'], 'prefix' => $item['prefix'], 'price' => $item['price'], 'sku' => $item['sku'], 'weight' => $item['weight'], 'weight_type' => $item['weight_type']);
                     //check if need to track stock and we have it
                     if ($item['subtract'] && $item['quantity'] < $quantity) {
                         $stock = FALSE;
                     }
                     $op_stock_trackable += $option_value_query['subtract'];
                 }
                 unset($option_value_queries);
             }
         }
     }
     // end of options build
     //needed for promotion
     $discount_quantity = 0;
     // this is used to calculate total QTY of 1 product in the cart
     // check is product is in cart and calculate quantity to define item price with product discount
     foreach ($this->cust_data['cart'] as $k => $v) {
         $array2 = explode(':', $k);
         if ($array2[0] == $product_id) {
             $discount_quantity += $v['qty'];
         }
     }
     if (!$discount_quantity) {
         $discount_quantity = $quantity;
     }
     //Apply group and quantity discount first and if non, reply product discount
     $price = $this->promotion->getProductQtyDiscount($product_id, $discount_quantity);
     if (!$price) {
         $price = $this->promotion->getProductSpecial($product_id);
     }
     //Still no special price, use regulr price
     if (!$price) {
         $price = $product_query['price'];
     }
     foreach ($option_data as $item) {
         if ($item['prefix'] == '%') {
             $option_price += $price * $item['price'] / 100;
         } else {
             $option_price += $item['price'];
         }
     }
     // product downloads
     $download_data = $this->download->getProductOrderDownloads($product_id);
     //check if we need to check main product stock. Do only if no stock trakable options selected
     if (!$op_stock_trackable && $product_query['subtract'] && $product_query['quantity'] < $quantity) {
         $stock = FALSE;
     }
     $result = array('product_id' => $product_query['product_id'], 'name' => $product_query['name'], 'model' => $product_query['model'], 'shipping' => $product_query['shipping'], 'option' => $option_data, 'download' => $download_data, 'quantity' => $quantity, 'minimum' => $product_query['minimum'], 'maximum' => $product_query['maximum'], 'stock' => $stock, 'price' => $price + $option_price, 'total' => ($price + $option_price) * $quantity, 'tax_class_id' => $product_query['tax_class_id'], 'weight' => $product_query['weight'], 'weight_class' => $product_query['weight_class'], 'length' => $product_query['length'], 'width' => $product_query['width'], 'height' => $product_query['height'], 'length_class' => $product_query['length_class'], 'ship_individually' => $product_query['ship_individually'], 'shipping_price' => $product_query['shipping_price'], 'free_shipping' => $product_query['free_shipping'], 'sku' => $product_query['sku']);
     return $result;
 }
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('product/special');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $url = '';
     if (isset($this->request->get['page'])) {
         $url .= '&page=' . $this->request->get['page'];
     }
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('product/special', $url), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator')));
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     if (isset($this->request->get['limit'])) {
         $limit = (int) $this->request->get['limit'];
         $limit = $limit > 50 ? 50 : $limit;
     } else {
         $limit = $this->config->get('config_catalog_limit');
     }
     if (isset($this->request->get['sort'])) {
         $sorting_href = $this->request->get['sort'];
         list($sort, $order) = explode("-", $sorting_href);
     } else {
         $sorting_href = $this->config->get('config_product_default_sort_order');
         list($sort, $order) = explode("-", $sorting_href);
         if ($sort == 'name') {
             $sort = 'pd.' . $sort;
         } elseif (in_array($sort, array('sort_order', 'price'))) {
             $sort = 'p.' . $sort;
         }
     }
     $this->loadModel('catalog/product');
     $promoton = new APromotion();
     $product_total = $promoton->getTotalProductSpecials();
     if ($product_total) {
         $this->loadModel('catalog/review');
         $this->loadModel('tool/seo_url');
         $this->loadModel('tool/image');
         $this->data['button_add_to_cart'] = $this->language->get('button_add_to_cart');
         $results = $promoton->getProductSpecials($sort, $order, ($page - 1) * $limit, $limit);
         $resource = new AResource('image');
         foreach ($results as $result) {
             $thumbnail = $resource->getMainThumb('products', $result['product_id'], (int) $this->config->get('config_image_product_width'), (int) $this->config->get('config_image_product_height'), true);
             if ($this->config->get('enable_reviews')) {
                 $rating = $this->model_catalog_review->getAverageRating($result['product_id']);
             } else {
                 $rating = false;
             }
             $special = FALSE;
             $discount = $promoton->getProductDiscount($result['product_id']);
             if ($discount) {
                 $price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
             } else {
                 $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
                 $special = $promoton->getProductSpecial($result['product_id']);
                 if ($special) {
                     $special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
                 }
             }
             $options = $this->model_catalog_product->getProductOptions($result['product_id']);
             if ($options) {
                 $add = $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode');
             } else {
                 if ($this->config->get('config_cart_ajax')) {
                     $add = '#';
                 } else {
                     $add = $this->html->getSecureURL('checkout/cart', '&product_id=' . $result['product_id'], '&encode');
                 }
             }
             //check for stock status, availability and config
             $track_stock = false;
             $in_stock = false;
             $no_stock_text = $result['stock'];
             $total_quantity = 0;
             if ($this->model_catalog_product->isStockTrackable($result['product_id'])) {
                 $track_stock = true;
                 $total_quantity = $this->model_catalog_product->hasAnyStock($result['product_id']);
                 //we have stock or out of stock checkout is allowed
                 if ($total_quantity > 0 || $this->config->get('config_stock_checkout')) {
                     $in_stock = true;
                 }
             }
             $this->data['products'][] = array('product_id' => $result['product_id'], 'name' => $result['name'], 'model' => $result['model'], 'rating' => $rating, 'stars' => sprintf($this->language->get('text_stars'), $rating), 'price' => $price, 'call_to_order' => $result['call_to_order'], 'options' => $options, 'special' => $special, 'thumb' => $thumbnail, 'href' => $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode'), 'add' => $add, 'description' => html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'), 'track_stock' => $track_stock, 'in_stock' => $in_stock, 'no_stock_text' => $no_stock_text, 'total_quantity' => $total_quantity);
         }
         if ($this->config->get('config_customer_price')) {
             $display_price = TRUE;
         } elseif ($this->customer->isLogged()) {
             $display_price = TRUE;
         } else {
             $display_price = FALSE;
         }
         $this->data['display_price'] = $display_price;
         $sorts = array();
         $sorts[] = array('text' => $this->language->get('text_default'), 'value' => 'p.sort_order-ASC', 'href' => $this->html->getURL('product/special', $url . '&sort=p.sort_order&order=ASC', '&encode'));
         $sorts[] = array('text' => $this->language->get('text_sorting_name_asc'), 'value' => 'pd.name-ASC', 'href' => $this->html->getURL('product/special', $url . '&sort=pd.name&order=ASC', '&encode'));
         $sorts[] = array('text' => $this->language->get('text_sorting_name_desc'), 'value' => 'pd.name-DESC', 'href' => $this->html->getURL('product/special', $url . '&sort=pd.name&order=DESC', '&encode'));
         $sorts[] = array('text' => $this->language->get('text_sorting_price_asc'), 'value' => 'ps.price-ASC', 'href' => $this->html->getURL('product/special', $url . '&sort=special&order=ASC', '&encode'));
         $sorts[] = array('text' => $this->language->get('text_sorting_price_desc'), 'value' => 'ps.price-DESC', 'href' => $this->html->getURL('product/special', $url . '&sort=special&order=DESC', '&encode'));
         $sorts[] = array('text' => $this->language->get('text_sorting_rating_desc'), 'value' => 'rating-DESC', 'href' => $this->html->getURL('product/special', $url . '&sort=rating&order=DESC', '&encode'));
         $sorts[] = array('text' => $this->language->get('text_sorting_rating_asc'), 'value' => 'rating-ASC', 'href' => $this->html->getURL('product/special', $url . '&sort=rating&order=ASC', '&encode'));
         $sorts[] = array('text' => $this->language->get('text_sorting_date_desc'), 'value' => 'date_modified-DESC', 'href' => $this->html->getSEOURL('product/special', $url . '&sort=date_modified&order=DESC', '&encode'));
         $sorts[] = array('text' => $this->language->get('text_sorting_date_asc'), 'value' => 'date_modified-ASC', 'href' => $this->html->getSEOURL('product/special', $url . '&sort=date_modified&order=ASC', '&encode'));
         $options = array();
         foreach ($sorts as $item) {
             $options[$item['value']] = $item['text'];
         }
         $sorting = $this->html->buildSelectbox(array('name' => 'sort', 'options' => $options, 'value' => $sort . '-' . $order));
         $this->view->assign('sorting', $sorting);
         $this->view->assign('url', $this->html->getURL('product/special'));
         $this->data['sorts'] = $sorts;
         $pagination_url = $this->html->getURL('product/special', '&sort=' . $sorting_href . '&page={page}' . '&limit=' . $limit, '&encode');
         $this->data['pagination_bootstrap'] = HtmlElementFactory::create(array('type' => 'Pagination', 'name' => 'pagination', 'text' => $this->language->get('text_pagination'), 'text_limit' => $this->language->get('text_per_page'), 'total' => $product_total, 'page' => $page, 'limit' => $limit, 'url' => $pagination_url, 'style' => 'pagination'));
         $this->data['sort'] = $sort;
         $this->data['order'] = $order;
         $this->data['review_status'] = $this->config->get('enable_reviews');
         $this->view->batchAssign($this->data);
         $this->view->setTemplate('pages/product/special.tpl');
     } else {
         $this->view->assign('text_error', $this->language->get('text_empty'));
         $continue = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button'));
         $this->view->assign('button_continue', $continue);
         $this->view->assign('continue', $this->html->getURL('index/home'));
         $this->view->setTemplate('pages/error/not_found.tpl');
     }
     $this->processTemplate();
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 private function _validateCoupon()
 {
     $this->loadLanguage('checkout/payment');
     $promotion = new APromotion();
     $coupon = $promotion->getCouponData($this->request->post['coupon']);
     if (!$coupon) {
         $this->error['warning'] = $this->language->get('error_coupon');
     }
     if (!$this->error) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
示例#13
0
 public function getProductSpecials($sort = 'p.sort_order', $order = 'ASC', $start = 0, $limit = 0)
 {
     $limit = (int) $limit;
     $limit = !$limit ? $this->config->get('config_special_limit') : $limit;
     $promoton = new APromotion();
     $results = $promoton->getProductSpecials($sort, $order, $start, $limit);
     return $results;
 }
示例#14
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->loadModel('tool/seo_url');
     $this->loadModel('catalog/category');
     if (isset($this->request->get['path'])) {
         $path = '';
         foreach (explode('_', $this->request->get['path']) as $path_id) {
             $category_info = $this->model_catalog_category->getCategory($path_id);
             if (!$path) {
                 $path = $path_id;
             } else {
                 $path .= '_' . $path_id;
             }
             if ($category_info) {
                 $this->document->addBreadcrumb(array('href' => $this->html->getSEOURL('product/category', '&path=' . $path, '&encode'), 'text' => $category_info['name'], 'separator' => $this->language->get('text_separator')));
             }
         }
     }
     $this->loadModel('catalog/manufacturer');
     if (isset($this->request->get['manufacturer_id'])) {
         $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']);
         if ($manufacturer_info) {
             $this->document->addBreadcrumb(array('href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $this->request->get['manufacturer_id'], '&encode'), 'text' => $manufacturer_info['name'], 'separator' => $this->language->get('text_separator')));
         }
     }
     if (isset($this->request->get['keyword'])) {
         $url = '';
         if (isset($this->request->get['category_id'])) {
             $url .= '&category_id=' . $this->request->get['category_id'];
         }
         if (isset($this->request->get['description'])) {
             $url .= '&description=' . $this->request->get['description'];
         }
         $this->document->addBreadcrumb(array('href' => $this->html->getURL('product/search', '&keyword=' . $this->request->get['keyword'] . $url, '&encode'), 'text' => $this->language->get('text_search'), 'separator' => $this->language->get('text_separator')));
     }
     $key = array();
     //key of product from cart
     if (has_value($this->request->get['key'])) {
         $key = explode(':', $this->request->get['key']);
         $product_id = (int) $key[0];
     } elseif (has_value($this->request->get['product_id'])) {
         $product_id = (int) $this->request->get['product_id'];
     } else {
         $product_id = 0;
     }
     $urls = array('is_group_option' => $this->html->getURL('r/product/product/is_group_option', '&product_id=' . $product_id, '&encode'));
     $this->view->assign('urls', $urls);
     $this->loadModel('catalog/product');
     $promoton = new APromotion();
     $product_info = $this->model_catalog_product->getProduct($product_id);
     //can not locate product? get out
     if (!$product_info) {
         $this->_product_not_found($product_id);
         return null;
     }
     $url = $this->_build_url();
     $this->view->assign('error', '');
     if (isset($this->session->data['error'])) {
         $this->view->assign('error', $this->session->data['error']);
         unset($this->session->data['error']);
     }
     $this->document->addBreadcrumb(array('href' => $this->html->getSEOURL('product/product', $url . '&product_id=' . $product_id, '&encode'), 'text' => $product_info['name'], 'separator' => $this->language->get('text_separator')));
     $this->document->setTitle($product_info['name']);
     $this->document->setKeywords($product_info['meta_keywords']);
     $this->document->setDescription($product_info['meta_description']);
     $this->document->addLink(array('href' => $this->html->getSEOURL('product/product', '&product_id=' . $product_id, '&encode'), 'rel' => 'canonical'));
     $this->data['heading_title'] = $product_info['name'];
     $this->data['minimum'] = $product_info['minimum'];
     $this->data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']);
     $this->data['maximum'] = $product_info['maximum'];
     $this->data['text_maximum'] = sprintf($this->language->get('text_maximum'), $product_info['maximum']);
     $this->data['option_resources_url'] = $this->html->getURL('r/product/product/get_option_resources');
     $this->data['calc_total_url'] = $this->html->getURL('r/product/product/calculateTotal');
     $this->data['product_review_url'] = $this->html->getURL('product/review/review', '&product_id=' . $product_id);
     $this->data['product_review_write_url'] = $this->html->getURL('product/review/write', '&product_id=' . $product_id);
     $this->data['product_wishlist_add_url'] = $this->html->getURL('product/wishlist/add', '&product_id=' . $product_id);
     $this->data['product_wishlist_remove_url'] = $this->html->getURL('product/wishlist/remove', '&product_id=' . $product_id);
     $this->data['captcha_url'] = $this->html->getURL('common/captcha');
     $this->loadModel('catalog/review');
     $this->data['tab_review'] = sprintf($this->language->get('tab_review'), $this->model_catalog_review->getTotalReviewsByProductId($product_id));
     if ($this->config->get('enable_reviews')) {
         $average = $this->model_catalog_review->getAverageRating($product_id);
     } else {
         $average = false;
     }
     $this->data['review_status'] = $this->config->get('enable_reviews');
     $this->data['text_stars'] = sprintf($this->language->get('text_stars'), $average);
     $this->data['rating_element'] = HtmlElementFactory::create(array('type' => 'rating', 'name' => 'rating', 'value' => '', 'options' => array(1 => 1, 2, 3, 4, 5), 'pack' => true));
     $this->data['review_name'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'name'));
     $this->data['review_text'] = HtmlElementFactory::create(array('type' => 'textarea', 'name' => 'text', 'attr' => ' rows="8" cols="50" '));
     $this->data['review_captcha'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'captcha', 'attr' => ''));
     $this->data['review_button'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'review_submit', 'text' => $this->language->get('button_submit'), 'style' => 'btn-primary', 'icon' => 'fa fa-comment'));
     $this->data['product_info'] = $product_info;
     $form = new AForm();
     $form->setForm(array('form_name' => 'product'));
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'product', 'action' => $this->html->getSecureURL('checkout/cart')));
     $product_price = $product_info['price'];
     $discount = $promoton->getProductDiscount($product_id);
     if ($discount) {
         $product_price = $discount;
         $this->data['price_num'] = $this->tax->calculate($discount, $product_info['tax_class_id'], (bool) $this->config->get('config_tax'));
         $this->data['special'] = FALSE;
     } else {
         $this->data['price_num'] = $this->tax->calculate($product_info['price'], $product_info['tax_class_id'], (bool) $this->config->get('config_tax'));
         $special = $promoton->getProductSpecial($product_id);
         if ($special) {
             $product_price = $special;
             $this->data['special_num'] = $this->tax->calculate($special, $product_info['tax_class_id'], (bool) $this->config->get('config_tax'));
         } else {
             $this->data['special'] = FALSE;
         }
     }
     $this->data['price'] = $this->currency->format($this->data['price_num']);
     if (isset($this->data['special_num'])) {
         $this->data['special'] = $this->currency->format($this->data['special_num']);
     }
     $product_discounts = $promoton->getProductDiscounts($product_id);
     $discounts = array();
     foreach ($product_discounts as $discount) {
         $discounts[] = array('quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], (bool) $this->config->get('config_tax'))));
     }
     $this->data['discounts'] = $discounts;
     $this->data['product_price'] = $product_price;
     $this->data['tax_class_id'] = $product_info['tax_class_id'];
     if (!$product_info['call_to_order']) {
         $this->data['form']['minimum'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'quantity', 'value' => $product_info['minimum'] ? (int) $product_info['minimum'] : 1, 'style' => 'short', 'attr' => ' size="3" '));
         $this->data['form']['add_to_cart'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'add_to_cart', 'text' => $this->language->get('button_add_to_cart'), 'style' => 'button1'));
     }
     $this->data['form']['product_id'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'product_id', 'value' => $product_id));
     $this->data['form']['redirect'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'redirect', 'value' => $this->html->getURL('product/product', $url . '&product_id=' . $product_id, '&encode')));
     $this->data['model'] = $product_info['model'];
     $this->data['manufacturer'] = $product_info['manufacturer'];
     $this->data['manufacturers'] = $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $product_info['manufacturer_id'], '&encode');
     $this->data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
     $this->data['product_id'] = $product_id;
     $this->data['average'] = $average;
     $resource = new AResource('image');
     $thumbnail = $resource->getMainThumb('manufacturers', $product_info['manufacturer_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true);
     if (!preg_match('/no_image/', $thumbnail['thumb_url'])) {
         $this->data['manufacturer_icon'] = $thumbnail['thumb_url'];
     }
     // Preapare options and values for display
     $elements_with_options = HtmlElementFactory::getElementsWithOptions();
     $options = array();
     $product_options = $this->model_catalog_product->getProductOptions($product_id);
     //get info from cart if key presents
     $cart_product_info = array();
     if ($key) {
         $cart_product_info = $this->cart->getProduct($this->request->get['key']);
     }
     foreach ($product_options as $option) {
         $values = array();
         $name = $price = '';
         $default_value = $cart_product_info['options'][$option['product_option_id']];
         if ($option['element_type'] == 'R') {
             $default_value = is_array($default_value) ? current($default_value) : (string) $default_value;
         }
         $preset_value = $default_value;
         foreach ($option['option_value'] as $option_value) {
             $default_value = $option_value['default'] && !$default_value ? $option_value['product_option_value_id'] : $default_value;
             // for case when trying to add to cart withot required options. we get option-array back inside _GET
             if (has_value($this->request->get['option'][$option['product_option_id']])) {
                 $default_value = $this->request->get['option'][$option['product_option_id']];
             }
             $name = $option_value['name'];
             //check if we disable options based on out of stock setting
             if ($option_value['subtract'] && $this->config->get('config_nostock_autodisable') && $option_value['quantity'] <= 0) {
                 continue;
             }
             //Apply option price modifier
             if ($option_value['prefix'] == '%') {
                 $price = $this->tax->calculate($product_price * $option_value['price'] / 100, $product_info['tax_class_id'], (bool) $this->config->get('config_tax'));
                 if ($price != 0) {
                     $price = $this->currency->format($price);
                 } else {
                     $price = '';
                 }
             } else {
                 $price = $this->tax->calculate($option_value['price'], $product_info['tax_class_id'], (bool) $this->config->get('config_tax'));
                 if ($price != 0) {
                     $price = $this->currency->format($price);
                 } else {
                     $price = '';
                 }
             }
             //Check stock and status
             $opt_stock_message = '';
             if ($option_value['subtract']) {
                 if ($option_value['quantity'] <= 0) {
                     //show out of stock message
                     $opt_stock_message = $product_info['stock_status'];
                 } else {
                     if ($this->config->get('config_stock_display')) {
                         $opt_stock_message = $option_value['quantity'] . " " . $this->language->get('text_instock');
                     }
                 }
             }
             $values[$option_value['product_option_value_id']] = $option_value['name'] . ' ' . $price . ' ' . $opt_stock_message;
         }
         //if not values are build, nothing to show
         if (count($values)) {
             $value = '';
             //add price to option name if it is not element with options
             if (!in_array($option['element_type'], $elements_with_options)) {
                 $option['name'] .= ' <small>' . $price . '</small>';
                 if ($opt_stock_message) {
                     $option['name'] .= '<br />' . $opt_stock_message;
                 }
                 $value = $default_value ? $default_value : $name;
             }
             //set default selection is nothing selected
             if (!has_value($value)) {
                 if (has_value($default_value)) {
                     $value = $default_value;
                 } else {
                     if (in_array($option['element_type'], $elements_with_options) && $option['element_type'] != 'S') {
                         //set first from the list to default
                         reset($values);
                         $value = key($values);
                     }
                 }
             }
             //for checkbox with empty value
             if ($value == '' && $option['element_type'] == 'C') {
                 $value = 1;
             }
             $option_data = array('type' => $option['html_type'], 'name' => !in_array($option['element_type'], HtmlElementFactory::getMultivalueElements()) ? 'option[' . $option['product_option_id'] . ']' : 'option[' . $option['product_option_id'] . '][]', 'value' => $value, 'options' => $values, 'required' => $option['required'], 'placeholder' => $option['option_placeholder'], 'regexp_pattern' => $option['regexp_pattern'], 'error_text' => $option['error_text']);
             if ($option['element_type'] == 'C') {
                 if (!in_array($value, array('0', '1'))) {
                     $option_data['label_text'] = $value;
                 }
                 $option_data['checked'] = $preset_value ? true : false;
             }
             $options[] = array('name' => $option['name'], 'html' => $this->html->buildElement($option_data));
         }
     }
     $this->data['options'] = $options;
     //handle stock messages
     // if track stock is off. no messages needed.
     if ($this->model_catalog_product->isStockTrackable($product_id)) {
         $total_quantity = $this->model_catalog_product->hasAnyStock($product_id);
         $this->data['track_stock'] = true;
         //out of stock if no quantity and no stick checkout is disabled
         if ($total_quantity <= 0 && !$this->config->get('config_stock_checkout')) {
             $this->data['in_stock'] = false;
             //show out of stock message
             $this->data['stock'] = $product_info['stock_status'];
         } else {
             $this->data['in_stock'] = true;
             if ($this->config->get('config_stock_display')) {
                 $this->data['stock'] = $product_info['quantity'];
             } else {
                 $this->data['stock'] = $this->language->get('text_instock');
             }
         }
         //check if we need to disable product for no stock
         if ($this->config->get('config_nostock_autodisable') && $total_quantity <= 0) {
             //set available data
             $pd_identifiers = "ID: " . $product_id;
             $pd_identifiers .= empty($product_info['model']) ? '' : " Model: " . $product_info['model'];
             $pd_identifiers .= empty($product_info['sku']) ? '' : " SKU: " . $product_info['sku'];
             $message_ttl = sprintf($this->language->get('notice_out_of_stock_ttl'), $product_info['name']);
             $message_txt = sprintf($this->language->get('notice_out_of_stock_body'), $product_info['name'], $pd_identifiers);
             //record to message box
             $msg = new AMessage();
             $msg->saveNotice($message_ttl, $message_txt);
             $this->model_catalog_product->updateStatus($product_id, 0);
             $this->redirect($this->html->getSEOURL('product/product', '&product_id=' . $product_info['product_id'], '&encode'));
         }
     }
     // main product image
     $sizes = array('main' => array('width' => $this->config->get('config_image_popup_width'), 'height' => $this->config->get('config_image_popup_height')), 'thumb' => array('width' => $this->config->get('config_image_thumb_width'), 'height' => $this->config->get('config_image_thumb_height')));
     $this->data['image_main'] = $resource->getResourceAllObjects('products', $product_id, $sizes, 1, false);
     if ($this->data['image_main']) {
         $this->data['image_main']['sizes'] = $sizes;
     }
     // additional images
     $sizes = array('main' => array('width' => $this->config->get('config_image_popup_width'), 'height' => $this->config->get('config_image_popup_height')), 'thumb' => array('width' => $this->config->get('config_image_additional_width'), 'height' => $this->config->get('config_image_additional_height')));
     $this->data['images'] = $resource->getResourceAllObjects('products', $product_id, $sizes, 0, false);
     $products = array();
     $results = $this->model_catalog_product->getProductRelated($product_id);
     foreach ($results as $result) {
         // related product image
         $sizes = array('main' => array('width' => $this->config->get('config_image_related_width'), 'height' => $this->config->get('config_image_related_height')), 'thumb' => array('width' => $this->config->get('config_image_related_width'), 'height' => $this->config->get('config_image_related_height')));
         $image = $resource->getResourceAllObjects('products', $result['product_id'], $sizes, 1);
         if ($this->config->get('enable_reviews')) {
             $rating = $this->model_catalog_review->getAverageRating($result['product_id']);
         } else {
             $rating = false;
         }
         $special = FALSE;
         $discount = $promoton->getProductDiscount($result['product_id']);
         if ($discount) {
             $price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], (bool) $this->config->get('config_tax')));
         } else {
             $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], (bool) $this->config->get('config_tax')));
             $special = $promoton->getProductSpecial($result['product_id']);
             if ($special) {
                 $special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], (bool) $this->config->get('config_tax')));
             }
         }
         $options = $this->model_catalog_product->getProductOptions($result['product_id']);
         if ($options) {
             $add = $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode');
         } else {
             if ($this->config->get('config_cart_ajax')) {
                 $add = '#';
             } else {
                 $add = $this->html->getSecureURL('checkout/cart', '&product_id=' . $result['product_id'], '&encode');
             }
         }
         $products[] = array('product_id' => $result['product_id'], 'name' => $result['name'], 'model' => $result['model'], 'rating' => $rating, 'stars' => sprintf($this->language->get('text_stars'), $rating), 'price' => $price, 'call_to_order' => $result['call_to_order'], 'options' => $options, 'special' => $special, 'image' => $image, 'href' => $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode'), 'add' => $add);
     }
     $this->data['related_products'] = $products;
     if ($this->config->get('config_customer_price')) {
         $display_price = TRUE;
     } elseif ($this->customer->isLogged()) {
         $display_price = TRUE;
     } else {
         $display_price = FALSE;
     }
     $this->data['display_price'] = $display_price;
     $this->model_catalog_product->updateViewed($product_id);
     $tags = array();
     $results = $this->model_catalog_product->getProductTags($product_id);
     foreach ($results as $result) {
         if ($result['tag']) {
             $tags[] = array('tag' => $result['tag'], 'href' => $this->html->getURL('product/search', '&keyword=' . $result['tag'], '&encode'));
         }
     }
     $this->data['tags'] = $tags;
     //downloads before order if allowed
     if ($this->config->get('config_download')) {
         $dwn = new ADownload();
         $download_list = $dwn->getDownloadsBeforeOrder($product_id);
         if ($download_list) {
             foreach ($download_list as $download) {
                 $href = $this->html->getURL('account/download/startdownload', '&download_id=' . $download['download_id']);
                 $download['attributes'] = $this->download->getDownloadAttributesValuesForCustomer($download['download_id']);
                 $download['button'] = $form->getFieldHtml(array('type' => 'button', 'id' => 'download_' . $download['download_id'], 'href' => $href, 'title' => $this->language->get('text_start_download'), 'text' => $this->language->get('text_start_download')));
                 $downloads[] = $download;
             }
             $this->data['downloads'] = $downloads;
         }
     }
     #check if product is in a wishlist
     $this->data['is_customer'] = false;
     if ($this->customer->isLogged() || $this->customer->isUnauthCustomer()) {
         $this->data['is_customer'] = true;
         $whishlist = $this->customer->getWishList();
         if ($whishlist[$product_id]) {
             $this->data['in_wishlist'] = true;
         }
     }
     $this->view->setTemplate('pages/product/product.tpl');
     $this->view->batchAssign($this->data);
     $this->processTemplate();
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
示例#15
0
 public function main()
 {
     if ($this->html_cache()) {
         return;
     }
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('blocks/special');
     $this->data['heading_title'] = $this->language->get('heading_title', 'blocks/special');
     $this->loadModel('catalog/product');
     $this->loadModel('catalog/review');
     $this->loadModel('tool/seo_url');
     $this->loadModel('tool/image');
     $promotion = new APromotion();
     $this->data['button_add_to_cart'] = $this->language->get('button_add_to_cart');
     $this->data['products'] = array();
     $results = $promotion->getSpecialProducts(array('sort' => 'pd.name', 'order' => 'ASC', 'start' => 0, 'limit' => $this->config->get('config_special_limit'), 'avg_rating' => $this->config->get('enable_reviews')));
     $product_ids = array();
     foreach ($results as $result) {
         $product_ids[] = (int) $result['product_id'];
     }
     //get thumbnails by one pass
     $resource = new AResource('image');
     $thumbnails = $resource->getMainThumbList('products', $product_ids, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
     $stock_info = $this->model_catalog_product->getProductsStockInfo($product_ids);
     foreach ($results as $result) {
         $thumbnail = $thumbnails[$result['product_id']];
         $special = FALSE;
         $discount = $result['discount_price'];
         if ($discount) {
             $price = $discount;
         } else {
             $price = $result['price'];
             $special = $promotion->getProductSpecial($result['product_id']);
             if ($special) {
                 $special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
             }
         }
         $price = $this->currency->format($this->tax->calculate($price, $result['tax_class_id'], $this->config->get('config_tax')));
         $options = $this->model_catalog_product->getProductOptions($result['product_id']);
         if ($options) {
             $add = $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode');
         } else {
             if ($this->config->get('config_cart_ajax')) {
                 $add = '#';
             } else {
                 $add = $this->html->getSecureURL('checkout/cart', '&product_id=' . $result['product_id'], '&encode');
             }
         }
         //check for stock status, availability and config
         $track_stock = false;
         $in_stock = false;
         $no_stock_text = $result['stock'];
         $total_quantity = 0;
         if ($stock_info[$result['product_id']]['subtract']) {
             $track_stock = true;
             $total_quantity = $stock_info[$result['product_id']]['quantity'];
             //we have stock or out of stock checkout is allowed
             if ($total_quantity > 0 || $this->config->get('config_stock_checkout')) {
                 $in_stock = true;
             }
         }
         $this->data['products'][] = array('product_id' => $result['product_id'], 'name' => $result['name'], 'blurb' => $result['blurb'], 'model' => $result['model'], 'rating' => (int) $result['rating'], 'stars' => sprintf($this->language->get('text_stars'), (int) $result['rating']), 'price' => $price, 'call_to_order' => $result['call_to_order'], 'options' => $options, 'special' => $special, 'thumb' => $thumbnail, 'href' => $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode'), 'add' => $add, 'track_stock' => $track_stock, 'in_stock' => $in_stock, 'no_stock_text' => $no_stock_text, 'total_quantity' => $total_quantity, 'date_added' => $result['date_added']);
     }
     if ($this->config->get('config_customer_price')) {
         $this->data['display_price'] = TRUE;
     } elseif ($this->customer->isLogged()) {
         $this->data['display_price'] = TRUE;
     } else {
         $this->data['display_price'] = FALSE;
     }
     $this->data['review_status'] = $this->config->get('enable_reviews');
     // framed needs to show frames for generic block.
     //If tpl used by listing block framed was set by listing block settings
     $this->data['block_framed'] = true;
     $this->view->batchAssign($this->data);
     $this->processTemplate();
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
示例#16
0
 /**
  * @param string $sort
  * @param string $order
  * @param int $start
  * @param int $limit
  * @return array
  */
 public function getProductSpecials($sort = 'p.sort_order', $order = 'ASC', $start = 0, $limit = 0)
 {
     $limit = (int) $limit;
     $promotion = new APromotion();
     $results = $promotion->getProductSpecials($sort, $order, $start, $limit);
     return $results;
 }