| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/junkdata/nammall/application/models/ |
Upload File : |
<?php
class DCB_Model_CRUD extends Zend_Db_Table_Abstract {
function init() {
$this->db = Zend_Db_Table::getDefaultAdapter();
$this->_Cart = new Zend_Session_Namespace('Cart');
}
public function mk_insert($tablename, array $addData) {
$dbtable = new Zend_Db_Table($tablename);
return $dbtable->insert($addData); // return inserted id
}
public function mk_update($tablename, array $editData, array $where) {
$dbtable = new Zend_Db_Table($tablename);
return $dbtable->update($editData, $where); // return row effected or not
}
public function mk_delete($table, $where) {
$dbtable = new Zend_Db_Table($table);
return $dbtable->delete($where);
}
/**
* rv_select_all() method is used to get all listing
* @param table name, columns array, where array, order array
* @return array result set
*/
public function mk_select_all($tablename, array $columns, array $where, array $order, $limit = false) {
$dbtable = new Zend_Db_Table($tablename);
$select = $dbtable->select()->from("$tablename as tbl", $columns);
if (count($where)) {
foreach ($where as $k => $v)
$select->where("$k =?", "$v");
}
if (count($order)) {
foreach ($order as $k => $v)
$select->order("$k $v");
}
if ($limit) {
$select->limit($limit);
}
$result = $dbtable->fetchAll($select);
if ($result == NULL)
return false;
else
return $result->toArray();
}
public function selectOne($tablename, array $columns, array $where) {
//echo "hello";die;
$dbtable = new Zend_Db_Table($tablename);
$select = $dbtable->select()->from("$tablename as tbl", $columns);
if (count($where)) {
foreach ($where as $k => $v) {
$select->where("$k =?", "$v");
}
}
$result = $dbtable->fetchRow($select);
return $result;
}
/**
* rv_select_row() method is used to get all listing
* @param table name, columns array, where array, order array
* @return array result set
*/
public function mk_select_row($tablename, array $columns, array $where, array $order = array()) {
$dbtable = new Zend_Db_Table($tablename);
$select = $dbtable->select()->from("$tablename as tbl", $columns);
if (count($where)) {
foreach ($where as $k => $v) {
$select->where("$k =?", "$v");
}
}
if (count($order)) {
foreach ($order as $k => $v)
$select->order("$k $v");
}
$result = $dbtable->fetchRow($select);
if ($result == NULL)
return false;
else
return $result->toArray();
}
/**
* rv_select_row_where_custom() method is used to get all listing
* @param table name, columns array, where array, order array
* @return array result set
*/
public function mk_select_row_where_custom($tablename, array $columns, array $where, $whereCustom, array $order, $limit = false) {
$dbtable = new Zend_Db_Table($tablename);
$select = $dbtable->select()->from("$tablename as tbl", $columns);
if (count($where)) {
foreach ($where as $k => $v)
$select->where("$k =?", "$v");
}
if (!empty($whereCustom)) {
$select->where("$whereCustom");
}
if (count($order)) {
foreach ($order as $k => $v)
$select->order("$k $v");
}
if ($limit) {
$select->limit($limit);
}
$result = $dbtable->fetchRow($select);
if ($result == NULL)
return false;
else
return $result->toArray();
}
public function getCmsdata($tablename, array $columns, array $where, array $order) {
$dbtable = new Zend_Db_Table($tablename);
$select = $dbtable->select()->from("$tablename as tbl", $columns);
if (count($where)) {
foreach ($where as $k => $v) {
$select->where("$k =?", "$v");
}
}
if (count($order)) {
foreach ($order as $k => $v)
$select->order("$k $v");
}
$result = $dbtable->fetchRow($select);
return $result;
}
/**
* rv_rowExists() method is used to check state name exists or not in db
* @param table name, columns array, where array, order array
* @return array result set
*/
public function mk_rowExists($tablename, array $columns, array $where, array $order) {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $dbtable->select()->from("$tablename as tbl", $columns);
if (count($where)) {
foreach ($where as $k => $v)
$select->where("$k =?", "$v");
}
if (count($order)) {
foreach ($order as $k => $v)
$select->order("$k $v");
}
$result = $dbtable->fetchOne($select);
return $result;
}
public function getCategoryListWithSubCategory() {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Master_category"), array("*"))
->joinLeft(array('T2' => "Master_subcategory"), "T1.id = T2.Category_id", array("Category_id", "Name as subCatName"))
->where("T1.IsMarkForDelete =?", 0)
->where("T1.IsActive =?", 1)
->where("T2.IsMarkForDelete =?", 0)
->where("T2.IsActive =?", 1);
$result = $dbObj->fetchAll($select);
return $result;
}
public function getTopDealProduct() {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Master_category"), array('Name as categoryName', 'id as categoryId'))
->joinLeft(array('T2' => "Master_subcategory"), "T1.id = T2.Category_id", array('Name as subCategoryName'))
->joinLeft(array('T3' => "Catalog_product"), "T2.id = T3.SubCategory_id", array('id', 'Name as productName', 'Brand_id', 'Description','SubCategory_id','DisplayText'))
->joinLeft(array('T4' => "Catalog_productprice"), "T3.id = T4.Product_id", array('Price', 'Color as colorName', 'id as priceId'))
->joinLeft(array('T5' => "Catalog_productimage"), "T3.id = T5.Product_id", array('image'))
//->joinLeft(array('T6' => "Master_color"), "T4.Color_id = T6.id",array('Name as colorName'))
->joinLeft(array('T7' => "Master_brand"), "T3.Brand_id = T7.id", array('Name as brandName'))
->joinLeft(array('T8' => "Catalog_product_Section"), "T3.id = T8.product_id", array('product_id'))
->where("T3.IsMarkForDelete =?", 0)
->where("T3.IsActive =?", 1)
->where("T5.order =?", 1)
->where("T4.Price >?", 0)
->where("T8.section_id =?", 4)
->group("T3.id");
if (isset($this->searchArr) && !empty($this->searchArr)) {
if (isset($this->searchArr['brand']) && $this->searchArr['brand'] != "") {
$brand = $this->searchArr['brand'];
$select->where('T3.Brand_id IN('.$brand.')');
}
if ($this->searchArr['minprice'] != "" && $this->searchArr['maxprice'] != "") {
$minprice = $this->searchArr['minprice'];
$maxprice = $this->searchArr['maxprice'];
$select->where('T4.Price BETWEEN '.$minprice.' AND '.$maxprice);
}
if (isset($this->searchArr['subcategory']) && $this->searchArr['subcategory'] != "") {
$subcategory = $this->searchArr['subcategory'];
$select->where("T2.Name like ? ", "%$subcategory%");
}
}
if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "ASC") {
$select->order("T4.Price ASC");
}else if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "DESC") {
$select->order("T4.Price DESC");
}else if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "NEW") {
$select->order("T3.id DESC");
}else{
$select->order("T4.Price ASC");
}
//->order('T3.id DESC,T4.Price')
$select->limit(10);
//echo $select; exit;
$result = $dbObj->fetchAll($select);
return $result;
}
public function getExclusiveDealsProduct() {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Master_category"), array('Name as categoryName', 'id as categoryId'))
->joinLeft(array('T2' => "Master_subcategory"), "T1.id = T2.Category_id", array('Name as subCategoryName'))
->joinLeft(array('T3' => "Catalog_product"), "T2.id = T3.SubCategory_id", array('id', 'Name as productName', 'Brand_id', 'Description','SubCategory_id'))
->joinLeft(array('T4' => "Catalog_productprice"), "T3.id = T4.Product_id", array('Price', 'Color as colorName', 'id as priceId'))
->joinLeft(array('T5' => "Catalog_productimage"), "T3.id = T5.Product_id", array('image'))
//->joinLeft(array('T6' => "Master_color"), "T4.Color_id = T6.id",array('Name as colorName'))
->joinLeft(array('T7' => "Master_brand"), "T3.Brand_id = T7.id", array('Name as brandName'))
->joinLeft(array('T8' => "Catalog_product_Section"), "T3.id = T8.product_id", array('product_id'))
->where("T3.IsMarkForDelete =?", 0)
->where("T3.IsActive =?", 1)
->where("T5.order =?", 1)
->where("T4.Price >?", 0)
->where("T8.section_id =?", 2)
->group("T3.id");
if (isset($this->searchArr) && !empty($this->searchArr)) {
if (isset($this->searchArr['brand']) && $this->searchArr['brand'] != "") {
$brand = $this->searchArr['brand'];
$select->where('T3.Brand_id IN('.$brand.')');
}
if ($this->searchArr['minprice'] != "" && $this->searchArr['maxprice'] != "") {
$minprice = $this->searchArr['minprice'];
$maxprice = $this->searchArr['maxprice'];
$select->where('T4.Price BETWEEN '.$minprice.' AND '.$maxprice);
}
if (isset($this->searchArr['subcategory']) && $this->searchArr['subcategory'] != "") {
$subcategory = $this->searchArr['subcategory'];
$select->where("T2.Name like ? ", "%$subcategory%");
}
}
if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "ASC") {
$select->order("T4.Price ASC");
}else if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "DESC") {
$select->order("T4.Price DESC");
}else if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "NEW") {
$select->order("T3.id DESC");
}else{
$select->order("T4.Price ASC");
}
//->order('T3.id DESC,T4.Price')
$select->limit(10);
$result = $dbObj->fetchAll($select);
return $result;
}
public function getPreferedProduct() {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Master_category"), array('Name as categoryName', 'id as categoryId'))
->joinLeft(array('T2' => "Master_subcategory"), "T1.id = T2.Category_id", array('Name as subCategoryName'))
->joinLeft(array('T3' => "Catalog_product"), "T2.id = T3.SubCategory_id", array('id', 'Name as productName', 'Brand_id', 'Description','SubCategory_id'))
->joinLeft(array('T4' => "Catalog_productprice"), "T3.id = T4.Product_id", array('Price', 'Color as colorName', 'id as priceId'))
->joinLeft(array('T5' => "Catalog_productimage"), "T3.id = T5.Product_id", array('image'))
//->joinLeft(array('T6' => "Master_color"), "T4.Color_id = T6.id",array('Name as colorName'))
->joinLeft(array('T7' => "Master_brand"), "T3.Brand_id = T7.id", array('Name as brandName'))
->joinLeft(array('T8' => "Catalog_product_Section"), "T3.id = T8.product_id", array('product_id'))
->where("T3.IsMarkForDelete =?", 0)
->where("T3.IsActive =?", 1)
->where("T5.order =?", 1)
->where("T4.Price >?", 0)
->where("T8.section_id =?", 3)
->group("T3.id");
if (isset($this->searchArr) && !empty($this->searchArr)) {
if (isset($this->searchArr['brand']) && $this->searchArr['brand'] != "") {
$brand = $this->searchArr['brand'];
$select->where('T3.Brand_id IN('.$brand.')');
}
if ($this->searchArr['minprice'] != "" && $this->searchArr['maxprice'] != "") {
$minprice = $this->searchArr['minprice'];
$maxprice = $this->searchArr['maxprice'];
$select->where('T4.Price BETWEEN '.$minprice.' AND '.$maxprice);
}
if (isset($this->searchArr['subcategory']) && $this->searchArr['subcategory'] != "") {
$subcategory = $this->searchArr['subcategory'];
$select->where("T2.Name like ? ", "%$subcategory%");
}
}
if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "ASC") {
$select->order("T4.Price ASC");
}else if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "DESC") {
$select->order("T4.Price DESC");
}else if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "NEW") {
$select->order("T3.id DESC");
}else{
$select->order("T4.Price ASC");
}
//->order('T3.id DESC,T4.Price')
$select->limit(10);
$result = $dbObj->fetchAll($select);
return $result;
}
public function getOwnOriginProduct() {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Master_category"), array('Name as categoryName', 'id as categoryId'))
->joinLeft(array('T2' => "Master_subcategory"), "T1.id = T2.Category_id", array('Name as subCategoryName'))
->joinLeft(array('T3' => "Catalog_product"), "T2.id = T3.SubCategory_id", array('id', 'Name as productName', 'Brand_id', 'Description','SubCategory_id'))
->joinLeft(array('T4' => "Catalog_productprice"), "T3.id = T4.Product_id", array('Price', 'Color as colorName', 'id as priceId'))
->joinLeft(array('T5' => "Catalog_productimage"), "T3.id = T5.Product_id", array('image'))
//->joinLeft(array('T6' => "Master_color"), "T4.Color_id = T6.id",array('Name as colorName'))
->joinLeft(array('T7' => "Master_brand"), "T3.Brand_id = T7.id", array('Name as brandName'))
->joinLeft(array('T8' => "Catalog_product_Section"), "T3.id = T8.product_id", array('product_id'))
->where("T3.IsMarkForDelete =?", 0)
->where("T3.IsActive =?", 1)
->where("T5.order =?", 1)
->where("T4.Price >?", 0)
->where("T8.section_id =?", 1)
->group("T3.id");
if (isset($this->searchArr) && !empty($this->searchArr)) {
if (isset($this->searchArr['brand']) && $this->searchArr['brand'] != "") {
$brand = $this->searchArr['brand'];
$select->where('T3.Brand_id IN('.$brand.')');
}
if ($this->searchArr['minprice'] != "" && $this->searchArr['maxprice'] != "") {
$minprice = $this->searchArr['minprice'];
$maxprice = $this->searchArr['maxprice'];
$select->where('T4.Price BETWEEN '.$minprice.' AND '.$maxprice);
}
if (isset($this->searchArr['subcategory']) && $this->searchArr['subcategory'] != "") {
$subcategory = $this->searchArr['subcategory'];
$select->where("T2.Name like ? ", "%$subcategory%");
}
}
if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "ASC") {
$select->order("T4.Price ASC");
}else if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "DESC") {
$select->order("T4.Price DESC");
}else if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "NEW") {
$select->order("T3.id DESC");
}else{
$select->order("T4.Price ASC");
}
//->order('T3.id DESC,T4.Price')
$select->limit(10);
$result = $dbObj->fetchAll($select);
return $result;
}
public function getLatestProduct() {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Catalog_product"), array("*"))
//->joinLeft(array('T2' => "Catalog_product_Section"), "T1.id = T2.product_id")
->joinLeft(array('T3' => "Catalog_productprice"), "T1.id = T3.Product_id", array('Price'))
->joinLeft(array('T4' => "Catalog_productimage"), "T1.id = T4.Product_id", array('image'))
->where("T1.IsMarkForDelete =?", 0)
->where("T1.IsActive =?", 1)
->where("T4.order =?", 1)
->where("T3.Price >?", 0)
->group("T1.id")
->order('T1.id DESC,T3.Price')
->limit(10);
//echo $select; exit;
$result = $dbObj->fetchAll($select);
return $result;
}
public function getProductByCategorysubCategory($cat, $subcat) {
$dbObj = Zend_Db_Table::getDefaultAdapter();
if ($subcat != '') {
$select = $dbObj->select()->from(array("T1" => "Master_subcategory"), array('Name as categoryName'))
->joinLeft(array('T2' => "Catalog_product"), "T1.id = T2.SubCategory_id", array('id', 'Name as productName', 'Brand_id', 'Description','SubCategory_id'))
->joinLeft(array('T3' => "Catalog_productprice"), "T2.id = T3.Product_id", array('Price', 'Color as colorName', 'id as priceId'))
->joinLeft(array('T4' => "Catalog_productimage"), "T2.id = T4.Product_id", array('image'))
->joinLeft(array('T5' => "Master_category"), "T1.Category_id = T5.id", array('Name as categoryName', 'id as categoryId'))
//->joinLeft(array('T6' => "Master_color"), "T3.Color_id = T6.id",array('Name as colorName'))
->joinLeft(array('T7' => "Master_brand"), "T2.Brand_id = T7.id", array('Name as brandName'))
->where("T1.Name like ? ", "%$subcat%")
->where("T2.Name != ''")
->where("T4.order =?", 1)
->where("T3.Price > ?", 0);
if (isset($this->searchArr) && !empty($this->searchArr)) {
if (isset($this->searchArr['brand']) && $this->searchArr['brand'] != "") {
$brand = $this->searchArr['brand'];
$select->where('T2.Brand_id IN('.$brand.')');
}
if ($this->searchArr['minprice'] != "" && $this->searchArr['maxprice'] != "") {
$minprice = $this->searchArr['minprice'];
$maxprice = $this->searchArr['maxprice'];
$select->where('T3.Price BETWEEN '.$minprice.' AND '.$maxprice);
}
if (isset($this->searchArr['subcategory']) && $this->searchArr['subcategory'] != "") {
$subcategory = $this->searchArr['subcategory'];
$select->where("T1.Name like ? ", "%$subcategory%");
}
}
if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "ASC") {
$select->order("T3.Price ASC");
}else if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "DESC") {
$select->order("T3.Price DESC");
}else if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "NEW") {
$select->order("T2.id DESC");
}else{
$select->order("T3.Price ASC");
}
} else {
$select = $dbObj->select()->from(array("T1" => "Master_category"), array('Name as categoryName', 'id as categoryId'))
->joinLeft(array('T2' => "Master_subcategory"), "T1.id = T2.Category_id", array('Name as subCategoryName'))
->joinLeft(array('T3' => "Catalog_product"), "T2.id = T3.SubCategory_id", array('id', 'Name as productName', 'Brand_id', 'Description','SubCategory_id'))
->joinLeft(array('T4' => "Catalog_productprice"), "T3.id = T4.Product_id", array('Price', 'Color as colorName', 'id as priceId'))
->joinLeft(array('T5' => "Catalog_productimage"), "T3.id = T5.Product_id", array('image'))
//->joinLeft(array('T6' => "Master_color"), "T4.Color_id = T6.id",array('Name as colorName'))
->joinLeft(array('T7' => "Master_brand"), "T3.Brand_id = T7.id", array('Name as brandName'))
->where("T1.Name like ? ", "%$cat%")
->where("T3.Name != ''")
->where("T5.order =?", 1)
->where("T4.Price > ?", 0);
if (isset($this->searchArr) && !empty($this->searchArr)) {
if (isset($this->searchArr['brand']) && $this->searchArr['brand'] != "") {
$brand = $this->searchArr['brand'];
$select->where('T3.Brand_id IN('.$brand.')');
}
if ($this->searchArr['minprice'] != "" && $this->searchArr['maxprice'] != "") {
$minprice = $this->searchArr['minprice'];
$maxprice = $this->searchArr['maxprice'];
$select->where('T4.Price BETWEEN '.$minprice.' AND '.$maxprice);
}
if (isset($this->searchArr['subcategory']) && $this->searchArr['subcategory'] != "") {
$subcategory = $this->searchArr['subcategory'];
$select->where("T2.Name like ? ", "%$subcategory%");
}
}
if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "ASC") {
$select->order("T4.Price ASC");
}else if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "DESC") {
$select->order("T4.Price DESC");
}else if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "NEW") {
$select->order("T3.id DESC");
}else{
$select->order("T4.Price ASC");
}
}
//echo $select;die;
$result = $dbObj->fetchAll($select);
return $result;
}
public function getAutoSuggestProductTag() {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Master_tagwords"), array('Name'));
$rowset = $dbObj->fetchAll($select);
$selectcategory = $dbObj->select()->from(array("T1" => "Master_category"), array('Name'));
$rowsetcategory = $dbObj->fetchAll($selectcategory);
$selectsubcategory = $dbObj->select()->from(array("T1" => "Master_subcategory"), array('Name'))
->joinLeft(array('T2' => "Master_category"), "T1.Category_id = T2.id", array('Name as categoryName'));
$rowsetsubcategory = $dbObj->fetchAll($selectsubcategory);
$selectproduct = $dbObj->select()->from(array("T1" => "Catalog_product"), array('Name'));
$rowsetproduct = $dbObj->fetchAll($selectproduct);
//$rowset = array_merge($rowset,$rowset1,$rowset2);
if (count($rowset) > 0) {
foreach ($rowset as $row) {
$response[] = array('label' => $row['Name'], 'title' => $row['Name'],'url'=>'shop/search-'.$this->getSeoName($row['Name']));
}
}
if (count($rowsetcategory) > 0) {
foreach ($rowsetcategory as $rowc) {
$response[] = array('label' => $rowc['Name'], 'title' => $rowc['Name'],'url'=>'shop/'.$this->getSeoName($rowc['Name']));
}
}
if (count($rowsetsubcategory) > 0) {
foreach ($rowsetsubcategory as $rows) {
$response[] = array('label' => $rows['Name'], 'title' => $rows['Name'],'url'=>'shop/'.$this->getSeoName($rows['categoryName']).'/'.$this->getSeoName($rows['Name']));
}
}
if (count($rowsetproduct) > 0) {
foreach ($rowsetproduct as $rowp) {
$response[] = array('label' => $rowp['Name'], 'title' => $rowp['Name'],'url'=>'product/'.$this->getSeoName($rowp['Name']));
}
}
return $response;
}
public function getAutoSuggestCityData() {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Master_city"), array('Name as Title','id as CityId'));
$rowset = $dbObj->fetchAll($select);
if (count($rowset) > 0) {
foreach ($rowset as $row) {
$response[] = array('label' => $row['Title'], 'title' => $row['Title'], 'CityId' => $row['CityId']);
}
}
return $response;
}
public function getCityDatabyId($id) {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Master_city"), array('Name as Title','id as CityId','State_id','Country_id'))
->joinLeft(array('T2' => "Master_country"), "T1.Country_id = T2.id", array('Name as CountryName'))
->joinLeft(array('T3' => "Master_state"), "T1.State_id = T3.id", array('Name as StateName'))
->where("T1.id =? ",$id);
$response = $dbObj->fetchAll($select);
return $response;
}
public function getProductByTagName($tag) {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Master_tagwords"), array('Name as tagName'))
->joinLeft(array('T2' => "Catalog_product_TagWords"), "T1.id = T2.tagwords_id", array(''))
->joinLeft(array('T3' => "Catalog_product"), "T2.product_id = T3.id", array('id', 'Name as productName', 'Description', 'Brand_id','SubCategory_id'))
->joinLeft(array('T4' => "Catalog_productprice"), "T3.id = T4.Product_id", array('Price', 'id as priceId'))
->joinLeft(array('T5' => "Catalog_productimage"), "T3.id = T5.Product_id", array('image'))
->joinLeft(array('T6' => "Master_subcategory"), "T3.SubCategory_id = T6.id", array('Name as subCategoryName'))
->joinLeft(array('T7' => "Master_category"), "T6.Category_id = T7.id", array('id as categoryId', 'Name as categoryName'))
->joinLeft(array('T8' => "Master_brand"), "T3.Brand_id = T8.id", array('Name as brandName'))
->where("T1.Name like ? ", "%$tag%")
->where("T3.Name != ''")
->where("T4.Price > ?", 0);
if (isset($this->searchArr) && !empty($this->searchArr)) {
if (isset($this->searchArr['brand']) && $this->searchArr['brand'] != "") {
$brand = $this->searchArr['brand'];
$select->where('T3.Brand_id IN('.$brand.')');
}
if ($this->searchArr['minprice'] != "" && $this->searchArr['maxprice'] != "") {
$minprice = $this->searchArr['minprice'];
$maxprice = $this->searchArr['maxprice'];
$select->where('T4.Price BETWEEN '.$minprice.' AND '.$maxprice);
}
if (isset($this->searchArr['subcategory']) && $this->searchArr['subcategory'] != "") {
$subcategory = $this->searchArr['subcategory'];
$select->where("T6.Name like ? ", "%$subcategory%");
}
}
if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "ASC") {
$select->order("T4.Price ASC");
}else if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "DESC") {
$select->order("T4.Price DESC");
}else if (isset($this->searchArr['sortbyorder']) && $this->searchArr['sortbyorder'] == "NEW") {
$select->order("T3.id DESC");
}else{
$select->order("T4.Price ASC");
}
//echo $select;die;
$result = $dbObj->fetchAll($select);
return $result;
}
public function getProductByName($prod) {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Catalog_product"), array("*"))
->joinLeft(array('T2' => "Catalog_product_Section"), "T1.id = T2.product_id", array(''))
->joinLeft(array('T3' => "Catalog_productprice"), "T1.id = T3.Product_id", array('Price', 'Cost', 'Color', 'id as PriceId'))
->joinLeft(array('T4' => "Catalog_productimage"), "T1.id = T4.Product_id", array('image', 'id as imageId'))
->joinLeft(array('T5' => "Catalog_supplier"), "T1.Supplier_id = T5.id", array('CompanyName', 'Email as SupplierEmail', 'id as SupplierSysId'))
->joinLeft(array('T6' => "Catalog_productitemfeatures"), "T1.id = T6.Product_id", array('itemFeatures', 'id as featureId'))
->joinLeft(array('T7' => "Catalog_productspecifications"), "T1.id = T7.Product_id", array('Value as prodSpecVal', 'Specifications_id'))
->joinLeft(array('T8' => "Master_specifications"), "T7.Specifications_id = T8.id", array('Name as specName', 'id as specId'))
->joinLeft(array('T9' => "Master_productoption"), "T3.ProductOption_id = T9.id", array('Name as productoption', 'id as productoptionId'))
->joinLeft(array('T10' => "Master_optionvalue"), "T3.OptionValue_id = T10.id", array('Name as optionvalue', 'id as optionvalueId'))
->where("T1.IsMarkForDelete =?", 0)
->where("T1.IsActive =?", 1)
->where("T3.Price > ?", 0)
->where("T1.Name like ? ", "%$prod%")
->order("T3.Price ASC");
//echo $select;die;
$result = $dbObj->fetchAll($select);
return $result;
}
public function getProductByCategoryId($categoryId) {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Catalog_product"), array("*"))
//->joinLeft(array('T2' => "Catalog_product_Section"), "T1.id = T2.product_id",array(''))
->joinLeft(array('T3' => "Catalog_productprice"), "T1.id = T3.Product_id", array('Price', 'Cost'))
->joinLeft(array('T4' => "Catalog_productimage"), "T1.id = T4.Product_id", array('image', 'id as imageId'))
->joinLeft(array('T5' => "Catalog_supplier"), "T1.Supplier_id = T5.id", array('CompanyName'))
->joinLeft(array('T6' => "Catalog_productitemfeatures"), "T1.id = T6.Product_id", array('itemFeatures', 'id as featureId'))
->where("T1.IsMarkForDelete =?", 0)
->where("T4.order =?", 1)
->where("T3.Price > ?", 0)
->where("T1.IsActive =?", 1)
->where("T1.SubCategory_id=? ", $categoryId)
->group("T1.id")
->order('T1.id DESC,T3.Price')
->limit(5);
//echo $select;die;
$result = $dbObj->fetchAll($select);
return $result;
}
public function getCustomerReview() {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Master_review"), array("*"))
->joinLeft(array('T2' => "Master_city"), "T2.id = T1.City_id", array('Name as CityName'))
->where("T1.IsMarkForDelete =?", 0)
->where("T1.IsActive =?", 1)
->where("T1.DisplayOnHome =?", 1)
->order("Id DESC")
->limit(4);
$result = $dbObj->fetchAll($select);
return $result;
}
public function sendNewsLetter($tablename, array $addData) {
$dbtable = new Zend_Db_Table($tablename);
return $dbtable->insert($addData); // return inserted id
}
public function checkLetter($tablename, array $columns, array $where) {
$dbtable = new Zend_Db_Table($tablename);
$select = $dbtable->select()->from("$tablename as tbl", $columns);
if (count($where)) {
foreach ($where as $k => $v)
$select->where("$k =?", "$v");
}
$result = $dbtable->fetchAll($select);
if ($result == NULL)
return false;
else
return $result->toArray();
}
public function cartProductList() {
$dbObj = Zend_Db_Table::getDefaultAdapter();
//echo "<pre>";print_r($_SESSION);die;
$ids = (isset($_SESSION['Cart']['session']['productIds']) && !empty($_SESSION['Cart']['session']['productIds'])) ? ltrim(rtrim($_SESSION['Cart']['session']['productIds'], ','), ',') : '';
if ($ids != '') {
$select = $dbObj->select()->from(array("T1" => "Catalog_product"), array('*'))
->joinLeft(array('T2' => "Catalog_productprice"), "T1.id = T2.Product_id", array('Price', 'id as priceId'))
->joinLeft(array('T3' => "Catalog_productimage"), "T1.id = T3.Product_id", array('image'))
->where("T1.id IN(" . $ids . ")");
//echo $select;die;
$result = $dbObj->fetchAll($select);
return $result;
} else {
return array();
}
}
public function cartProductListById($id) {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$ids = trim(implode(',', $_SESSION['products']['id']));
$select = $dbObj->select()->from(array("T1" => "Catalog_product"), array('*'))
->joinLeft(array('T2' => "Catalog_productprice"), "T1.id = T2.Product_id", array('Price', 'Color_id', 'id as priceId'))
->joinLeft(array('T3' => "Catalog_productimage"), "T1.id = T3.Product_id", array('image'))
->where("T1.id =?", $id);
$result = $dbObj->fetchAll($select);
return $result;
}
public function customerCheck($email, $mobile = NULL) {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Customer_customer"), array('*'));
$select->where("T1.Email =?", $email);
if($mobile){
$select->where("T1.Mobile =?", $mobile);
}
$result = $dbObj->fetchRow($select);
return $result;
}
public function sellerCheck($email, $mobile = NULL) {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Catalog_supplier"), array('*'));
$select->where("T1.Email =?", $email);
if($mobile){
$select->where("T1.Mobile =?", $mobile);
}
$result = $dbObj->fetchRow($select);
return $result;
}
public function customerCheckLogin($email, $password) {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Customer_customer"), array('*'))
->where("T1.Email =?", $email)
->where("T1.password =?", $password)
->where("T1.IsEmailVerify =?", 1);
$result = $dbObj->fetchRow($select);
return $result;
}
public function sellerCheckLogin($email, $password) {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Catalog_supplier"), array('*'))
->where("T1.Email =?", $email)
->where("T1.password =?", $password)
->where("T1.IsEmailVerify =?", 1);
$result = $dbObj->fetchRow($select);
return $result;
}
public function customerAddressDetail($customerId, $addressId) {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Customer_address"), array('*'))
->joinLeft(array('T2' => "Master_city"), "T1.City_id = T2.id", array('Name as cityName'))
->where("T1.Customer_id =?", $customerId)
->where("T1.id =?", $addressId);
$result = $dbObj->fetchRow($select);
return $result;
}
public function getSeoName($headline) {
//echo $headline;
$browse = array("_", "~", "'", "@", "#", "$", "%", "^", "*", "/", ";", ",", "|", "/", "\\");
$page_alias_name = strtolower(str_replace(" ", "-", str_replace($browse, "-", substr($headline, 0, 100))));
return str_replace(['---', '--'], '-', $page_alias_name);
}
public function getSubCategory($cat = NULL) {
$dbObj = Zend_Db_Table::getDefaultAdapter();
if ($cat) {
$select = $dbObj->select()->from(array("T1" => "Master_subcategory"), array('Name as categoryName', 'id as categoryId'))
->joinLeft(array('T5' => "Master_category"), "T1.Category_id = T5.id", array())
->where("T5.Name like ? ", "%$cat%");
$result = $dbObj->fetchAll($select);
return $result;
} else {
return array();
}
}
public function getProductItemDetail($priceId) {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Catalog_productprice"), array('*'))
->where("T1.id =?", $priceId);
$result = $dbObj->fetchRow($select);
return $result;
}
public function getSupplierCommissionDetail($supplierSysId) {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Catalog_supplier"), array(''))
->joinLeft(array('T5' => "Master_commissionmaster"), "T1.Commission_id = T5.id", array("Commission","CommissionType"))
->where("T1.id =?", $supplierSysId);
$result = $dbObj->fetchRow($select);
return $result;
}
public function getCustomerOrder($id){
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Order_order"), array('TotalCost','OrderId','CreatedOn'))
->joinLeft(array('T2' => "Order_orderitem"), "T1.id = T2.Order_id", array("Color","Quantity","Weight","Price as itemPrice",'id as itemId','SupplierStatus_id','ExpectedShippingDate'))
->joinLeft(array('T3' => "Catalog_product"), "T2.Product_id = T3.id", array("Name as ProductName"))
->joinLeft(array('T4' => "Master_color"), "T2.Color = T4.id",array('Name as colorName'))
->where("T1.Customer_id =?", $id);
$result = $dbObj->fetchAll($select);
return $result;
}
public function getSupplierOrder($id){
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Order_order"), array('TotalCost','OrderId','CreatedOn','Customer_id','Address_id'))
->joinLeft(array('T2' => "Order_orderitem"), "T1.id = T2.Order_id", array("Color","Quantity","Weight","Price as itemPrice",'id as itemId','SupplierStatus_id','ExpectedShippingDate'))
->joinLeft(array('T3' => "Catalog_product"), "T2.Product_id = T3.id", array("Name as ProductName"))
->joinLeft(array('T4' => "Master_color"), "T2.Color = T4.id",array('Name as colorName'))
->where("T2.Supplier_id =?", $id);
$result = $dbObj->fetchAll($select);
return $result;
}
public function getLastOrderId() {
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Order_order"), array('OrderId'))
->order("id DESC")
->limit(1);
$result = $dbObj->fetchRow($select);
// echo "<pre>";print_r($result);exit;
$OrderIdArray = isset($result['OrderId'])?$result['OrderId']:array();
if(empty($OrderIdArray)) {
$orderId = "NAM00000001";
} else {
$orderId = explode("NAM", $OrderIdArray);
$orderId = (int)$orderId[1]+1;
$orderId = "NAM".str_pad($orderId, 8, "0", STR_PAD_LEFT);
}
return $orderId;
}
public function getorderDetailByItemId($id){
$dbObj = Zend_Db_Table::getDefaultAdapter();
$select = $dbObj->select()->from(array("T1" => "Order_order"), array('TotalCost','OrderId','CreatedOn','Customer_id','Address_id'))
->joinLeft(array('T2' => "Order_orderitem"), "T1.id = T2.Order_id", array("Color","Quantity","Weight","Price as itemPrice",'id as itemId','SupplierStatus_id','ExpectedShippingDate'))
->joinLeft(array('T3' => "Catalog_product"), "T2.Product_id = T3.id", array("Name as ProductName",'NamhoItemCode'))
->joinLeft(array('T4' => "Customer_customer"), "T1.Customer_id = T4.id",array('Name as customerName','Email'))
->joinLeft(array('T5' => "Catalog_supplier"), "T2.Supplier_id = T5.id",array('Name as supplierName','Email as supplierEmailId'))
->joinLeft(array('T6' => "Master_orderstatus"), "T2.SupplierStatus_id = T6.id",array('Name as statusName'))
->where("T2.id =?", $id);
$result = $dbObj->fetchAll($select);
return $result;
}
}