Added admin tool for ivt product import
This commit is contained in:
@@ -41,8 +41,40 @@ class AdminController extends mfBaseController {
|
||||
protected function ivtImportMatchProductsAction() {
|
||||
$this->layout()->setTemplate("Admin/ivtimport_product_match");
|
||||
|
||||
$ivtproducts = IvtProductModel::getAll();
|
||||
$filter_name = MFAPPNAME.'-Admin-ivtimport_product-filter';
|
||||
if($this->request->resetFilter) {
|
||||
unset($_SESSION[$filter_name]);
|
||||
}
|
||||
|
||||
$filter = [];
|
||||
if(is_array($this->request->filter)) {
|
||||
$filter = $this->request->filter;
|
||||
$_SESSION[$filter_name] = $filter;
|
||||
} else {
|
||||
if(array_key_exists($filter_name, $_SESSION) && count($_SESSION[$filter_name])) {
|
||||
$filter = $_SESSION[$filter_name];
|
||||
}
|
||||
}
|
||||
|
||||
$this->layout->set("filter", $filter);
|
||||
//$filter = $this->getPreparedFilter($filter);
|
||||
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
$pagination['start'] = 0;
|
||||
$pagination['count'] = 20;
|
||||
$pagination['maxItems'] = 0;
|
||||
|
||||
if(is_numeric($this->request->s)) {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
//var_dump($filter);exit;
|
||||
$pagination['maxItems'] = IvtProductModel::count($filter);
|
||||
$ivtproducts = IvtProductModel::search($filter, $pagination);
|
||||
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
$this->layout()->set("ivtproducts", $ivtproducts);
|
||||
$this->layout()->set("products", ProductModel::getActive());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,12 +37,26 @@ class IvtProductModel {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) cnt FROM products WHERE $where ORDER by id";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM products $where ORDER by id";
|
||||
$sql = "SELECT * FROM products WHERE $where ORDER by id";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
if(is_array($limit) && count($limit)) {
|
||||
|
||||
Reference in New Issue
Block a user