/** * get order list */ function getProductList() { /** * get filter */ if ($_POST['product-list-filter']) { $filter = $_POST['product-list-filter']; } else { if (is_array($_SESSION['bo']['product-list-filter'])) { $filter = $_SESSION['bo']['product-list-filter']; } else { $filter = array(); } } /** * Initialize order object */ require_once 'models/ecommerce/ecommerce_product.php'; $Product = new ecommerce_product(); /** * Get order list */ $product_list = $Product->getFilteredProductList($filter); $product_list = array_reverse($product_list); return $product_list; }
/** * main action */ public function mainAction() { /** * get filter */ if ($_POST['product-list-filter']) { $filter = $_POST['product-list-filter']; } else { if (is_array($_SESSION['bo']['product-list-filter'])) { $filter = $_SESSION['bo']['product-list-filter']; } else { $filter = array(); } } /** * Initialize order object */ require_once 'models/ecommerce/ecommerce_product.php'; $Product = new ecommerce_product(); /** * Get order list */ $product_list = $Product->getFilteredProductList($filter); if (count($product_list) > 0) { /** * Initialize pagination variables */ if (is_numeric($this->GET['limit_from'])) { $from = $this->GET['limit_from']; } else { $from = 0; } if (is_numeric($this->GET['limit_per_page'])) { $per_page = $this->GET['limit_per_page']; } else { $per_page = 25; } $limit = "{$from},{$per_page}"; /** * Display pagination */ //$link = "/page/" . $_SESSION['active_pages'][0]; $count = count($product_list); $_Onxshop_Request = new Onxshop_Request("component/pagination~limit_from={$from}:limit_per_page={$per_page}:count={$count}~"); $this->tpl->assign('PAGINATION', $_Onxshop_Request->getContent()); /** * Display items * Implemented pagination */ $product_list = array_reverse($product_list); foreach ($product_list as $i => $item) { if ($i >= $from && $i < $from + $per_page) { $even_odd = 'odd' != $even_odd ? 'odd' : 'even'; $item['even_odd'] = $even_odd; $item['disabled'] = $item['publish'] ? '' : 'disabled'; $this->tpl->assign('ITEM', $item); $this->tpl->parse('content.item'); } } } else { $this->tpl->parse('content.empty'); } return true; }
/** * main action */ public function mainAction() { /** * Get input variables */ if ($_POST['product-list-filter']) { $filter = $_POST['product-list-filter']; } else { $filter = $_SESSION['bo']['product-list-filter']; } if (is_numeric($this->GET['taxonomy_tree_id'])) { $filter['taxonomy_json'] = json_encode(array($this->GET['taxonomy_tree_id'])); } else { $filter['taxonomy_json'] = false; } /** * Get the list */ require_once 'models/ecommerce/ecommerce_product.php'; $Product = new ecommerce_product(); $product_list = $Product->getFilteredProductList($filter); if (!is_array($product_list)) { return false; } if (count($product_list) == 0) { $this->tpl->parse('content.empty_list'); return true; } /** * Sorting */ //$_Onxshop_Request = new Onxshop_Request("component/ecommerce/product_list_sorting"); //$this->tpl->assign('SORTING', $_Onxshop_Request->getContent()); if ($this->GET['product-list-sort-by']) { $_SESSION['bo']['product-list-sort-by'] = $this->GET['product-list-sort-by']; } if ($this->GET['product-list-sort-direction']) { $_SESSION['bo']['product-list-sort-direction'] = $this->GET['product-list-sort-direction']; } if ($_SESSION['bo']['product-list-sort-by']) { $sortby = $_SESSION['bo']['product-list-sort-by']; } else { $sortby = "modified"; } if ($_SESSION['bo']['product-list-sort-direction']) { $direction = $_SESSION['bo']['product-list-sort-direction']; } else { $direction = "DESC"; } //msg("Sorted by $sortby $direction"); $product_list_sorted = array(); switch ($sortby) { default: case 'id': $product_list = php_multisort($product_list, array(array('key' => 'product_id', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric'))); break; case 'modified': $product_list = php_multisort($product_list, array(array('key' => 'modified', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric'))); break; case 'product_name': $product_list = php_multisort($product_list, array(array('key' => 'product_name', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric'))); break; case 'variety_name': $product_list = php_multisort($product_list, array(array('key' => 'variety_name', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric'))); break; case 'price': $product_list = php_multisort($product_list, array(array('key' => 'price', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric'))); break; case 'sku': $product_list = php_multisort($product_list, array(array('key' => 'sku', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric'))); break; case 'stock': $product_list = php_multisort($product_list, array(array('key' => 'stock', 'sort' => $direction), array('key' => 'product_id', 'type' => 'numeric'))); break; } foreach ($product_list as $item) { $product_list_sorted[] = $item; } $product_list = $product_list_sorted; //print_r($product_list);exit; /** * Reformat */ $pl = array(); foreach ($product_list as $item) { $pl[$item['product_id']][] = $item; } $product_list = array(); foreach ($pl as $item) { $product_list[] = $item; } /** * Initialize pagination variables */ if (is_numeric($this->GET['limit_from'])) { $from = $this->GET['limit_from']; } else { $from = 0; } if (is_numeric($this->GET['limit_per_page'])) { $per_page = $this->GET['limit_per_page']; } else { $per_page = 25; } $limit = "{$from},{$per_page}"; /** * Display pagination */ //$link = "/page/" . $_SESSION['active_pages'][0]; $count = count($product_list); $_Onxshop_Request = new Onxshop_Request("component/pagination~link=/request/bo/component/ecommerce/product_list:limit_from={$from}:limit_per_page={$per_page}:count={$count}~"); $this->tpl->assign('PAGINATION', $_Onxshop_Request->getContent()); /** * Parse items * Implemented pagination */ //print_r($product_list); exit; foreach ($product_list as $i => $p_item) { if ($i >= $from && $i < $from + $per_page) { $item = $p_item[0]; $rowspan = count($p_item); $this->tpl->assign('ROWSPAN', "rowspan='{$rowspan}'"); $item['disabled'] = $item['publish'] ? '' : 'disabled'; $this->tpl->assign('ITEM', $item); if ($item['image_src']) { $this->tpl->parse('content.list.item.imagetitle.image'); } $this->tpl->parse('content.list.item.imagetitle'); $even_odd = 'odd' != $even_odd ? 'odd' : 'even'; $this->tpl->assign('CLASS', "class='{$even_odd} fullproduct'"); foreach ($p_item as $item) { if ($item['variety_publish'] == 0) { $item['variety_publish'] = 'disabled'; } $this->checkNotifications($item); $this->tpl->assign('ITEM', $item); $this->tpl->parse('content.list.item'); $this->tpl->assign('CLASS', "class='{$even_odd}'"); } } } $this->tpl->parse('content.list'); return true; }