public function displayCategories($PageID = null, $limit = 8) { $products = new Model_Products(); if (!$PageID) { $page = $this->getData("Pages", "PageType='Home'"); if ($page) { $PageID = $page[0]['ID']; } else { return array(); } } else { $page = $this->getData("Pages", "ID=" . $PageID); } if ($page) { $page_categories = explode(",", $page[0]['Categories']); } $tmp = array(); foreach ($page_categories as $category_id) { if (strlen($category_id) > 0) { $tmp[] = $products->ListProducts(null, $category_id, null, null, $limit); } } $data = array(); foreach ($tmp as $row) { foreach ($row as $k => $v) { //echo '<pre>'; print_r( $v); exit; //$this->getProductAttributes($v['ProductID']); $data[$v['CatName']][$k] = $v; } } return $data; }
public function listCartItems($items = array()) { $product = new Model_Products(); $cart_items = array(); foreach ($items as $product_id) { $cart_items[] = $product->ListProducts($product_id); } return $cart_items; }
/** * Get additional content data selected * * @param $result = Query result */ public static function post_find($result) { if ($result !== null) { if (is_array($result)) { foreach ($result as $item) { // It will first check if we already have result in temporary result, // and only execute query if we dont. That way we dont have duplicate queries // Get products $item->get_products = static::lazy_load(function () use($item) { return Model_Products::find(array('where' => array('order_id' => $item->id))); }, $item->id, 'products'); // Get order payments $item->get_payments = static::lazy_load(function () use($item) { return \Payment\Model_Payment::find(array('where' => array('order_id' => $item->id), 'order_by' => array('id' => 'desc'))); }, $item->id, 'payments'); // Get last payment status $item->get_last_payment = static::lazy_load(function () use($item) { $payments = \Payment\Model_Payment::find(array('where' => array('order_id' => $item->id), 'order_by' => array('id' => 'desc'))); return isset($payments[0]) ? $payments[0] : array(); }, $item->id, 'last_payment', 'object'); } } } // return the result return $result; }
public function post_products() { Log::info(__METHOD__ . ": Start"); $params = Input::param(); $asin = $params['product_uid']; $obj = new Amazon_Product(Config::get('unique.amazon.public_key'), Config::get('unique.amazon.private_key')); $itemobj = $obj->getItemByAsin($asin); #Log::error(var_export($itemobj['Items'],true)); $item = $itemobj['Items']['Item']; $responce = array("asin" => $item['ASIN'], "title" => $item['ItemAttributes']['Title'], "image_url" => $item['LargeImage']['URL'], "detail_url" => "", "is_adult" => isset($item['ItemAttributes']['IsAdultProduct']) ? $item['ItemAttributes']['IsAdultProduct'] : 0); #Log::error(var_export($responce,true)); $ins_arr = array('id' => UUID::generate(UUID::UUID_RANDOM, UUID::FMT_STRING), 'product_uid' => $responce['asin'], 'product_type' => "amazon", 'title' => $responce['title'], 'image_url' => $responce['image_url'], 'detail_url' => $responce['detail_url'], 'is_adult' => $responce['is_adult']); $ins = new Model_Products($ins_arr); $_res = $ins->save(); $responce = array(); $this->response($responce, 200); }
/** * Get additional content data selected * * @param $result = Query result */ public static function post_find($result) { if ($result !== null) { if (is_array($result)) { foreach ($result as $item) { // It will first check if we already have result in temporary result, // and only execute query if we dont. That way we dont have duplicate queries // Get products $item->get_products = static::lazy_load(function () use($item) { return Model_Products::find(array('where' => array('order_id' => $item->id))); }, $item->id, 'products'); // Get order payments $item->get_payments = static::lazy_load(function () use($item) { return \Payment\Model_Payment::find(array('where' => array('order_id' => $item->id), 'order_by' => array('id' => 'desc'))); }, $item->id, 'payments'); // Get last payment status $item->get_last_payment = static::lazy_load(function () use($item) { $payments = \Payment\Model_Payment::find(array('where' => array('order_id' => $item->id), 'order_by' => array('id' => 'desc'))); return isset($payments[0]) ? $payments[0] : array(); }, $item->id, 'last_payment', 'object'); // Get history $item->get_history = static::lazy_load(function () use($item) { return Model_History::find(array('where' => array('order_id' => $item->id), 'order_by' => array('created_at' => 'desc'))); }, $item->id, 'history'); // Get artworks $item->get_artwork = static::lazy_load(function () use($item) { return Model_Artwork::find(array('where' => array('order_id' => $item->id))); }, $item->id, 'artwork'); // Get artworks status $item->get_artwork_status = static::lazy_load(function () use($item) { $out = array(0, 0); $products = Model_Products::find(array('where' => array('order_id' => $item->id, 'artwork_required' => 1))); if (!$products) { return $out; } $out[0] = count($products); foreach ($products as $product) { if ($product->artwork) { $out[1]++; } } return $out; }, $item->id, 'artwork_status', 'array'); // Get order user object $item->get_user = static::lazy_load(function () use($item) { return \Sentry::user((int) $item->user_id); }, $item->id, 'user', 'object'); } } } // return the result return $result; }
public function indexAction() { $this->_helper->layout()->setLayout('redesign-2014'); $Page = new Model_Page(); if ($this->_getParam('pid') == 'index') { //$this->_redirect('/'); } $pagedata = $Page->Display($this->_getParam('pid')); if (!$pagedata) { //check if product url $products = new Model_Products(); $product = $products->ListProductByURL($this->_getParam('pid')); if ($product) { $this->_helper->layout()->setLayout('redesign-2014-product'); $product_id = $product['ProductID']; $this->view->data = $product; $this->view->images = $products->DisplayProductImages($product_id); $this->view->pagetype = "product"; $this->view->product_page = 1; $this->view->site_title = $product['Name']; $this->view->product_categories = $products->DisplayProductCategories($product_id); $this->view->product_attributes = $products->DisplayProductAttributes($product_id); $this->render('product'); } else { throw new Zend_Controller_Action_Exception('This page does not exist', 404); } } else { $this->view->pagetype = "page"; $this->view->data = $pagedata; } if ($pagedata['PageType'] == 'About') { $site = new Model_Site(); $this->view->blurb_1 = $site->widget_blurb("Who We Are"); $this->view->blurb_2 = $site->widget_blurb("Our Mission"); $this->render('about'); } if ($pagedata['PageType'] == 'Contact') { $this->render('contact'); } }
/** * getModel * @return type Model * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ protected function getModel() { if ($this->objModel === null) { /** * autoload only handles "library" compoennts. * Since this is an application model, we need to require it * from its modules path location. */ $strModelFilePath = GLOBAL_ROOT_PATH . $this->core->sysConfig->path->zoolu_modules . $this->strModelSubPath . (substr($this->strType, strlen($this->strType) - 1) == 'y' ? ucfirst(rtrim($this->strType, 'y')) . 'ies' : ucfirst($this->strType) . 's') . '.php'; if (file_exists($strModelFilePath)) { require_once $strModelFilePath; $strModel = 'Model_' . (substr($this->strType, strlen($this->strType) - 1) == 'y' ? ucfirst(rtrim($this->strType, 'y')) . 'ies' : ucfirst($this->strType) . 's'); $this->objModel = new $strModel(); $this->objModel->setLanguageId($this->getRequest()->getParam("languageId", $this->core->intZooluLanguageId)); } else { throw new Exception('Not able to load type specific model, because the file didn\'t exist! - strType: "' . $this->strType . '"'); } } return $this->objModel; }
public function uploadProducts($filename) { $result = ['status' => '', 'message' => '', 'results' => []]; $filepath = 'temp/' . $filename; if (file_exists($filepath)) { if (($file = file_get_contents($filepath)) !== false) { $extension = pathinfo($filepath, PATHINFO_EXTENSION); switch ($extension) { case 'json': $products = json_decode($file); $model = new Model_Products(); for ($i = 0; $i < count($products); $i++) { $result['results'][$i] = $model->addProduct((array) $products[$i]); } break; case 'xml': $xml = simplexml_load_file($filepath); $model = new Model_Products(); // Небольшая валидация xml файла if ($xml && isset($xml->products) && isset($xml->products->product)) { $products = $xml->products; foreach ($products->product as $product) { $result['results'][] = $model->addProduct((array) $product); } } else { $result['status'] = 'error'; $result['message'] = 'Неправильный xml файл!'; return $result; } break; default: $result['status'] = 'error'; $result['message'] = 'Неверное расширение файла!'; return $result; break; } // Удаляем файл после того, как он загружен unlink($filepath); $result['status'] = 'success'; $result['message'] = 'Товары успешно добавлены'; } else { $result['status'] = 'error'; $result['message'] = 'Не удалось открыть файл=('; } } else { $result['status'] = 'error'; $result['message'] = 'Файла почему-то нет=('; } return $result; }
public function productsdeleteAction() { $products = new Model_Products(); $product_id = $this->_getParam('pid'); $confirmation = $this->_getParam('conf'); $products->RemoveProduct($product_id, $confirmation); $this->_redirect('/admin/productslist/'); }
public function AddMemberTransaction($data, $user_details) { $transid = $data['memcheckout']; //@todo validate this //excheckout $UserID = $user_details['ID']; $Email = $user_details['SiteEmail']; $Firstname = $user_details['Firstname']; $Lastname = $user_details['Lastname']; $Phone = isset($user_details['Phone1']) ? $user_details['Phone1'] : $data['Phone1']; $ShippingAddress = isset($data['ShippingAddress']) ? $data['ShippingAddress'] : $user_details['Address'] . ' ' . $user_details['City'] . ' ' . $user_details['Country'] . ' ' . $user_details['Zip']; $PaymentMethod = $data['PaymentMethod']; //process overrieds $products = $data['Product']; $purchase = array(); $purchase_qty = array(); foreach ($products as $id => $qty) { $purchase_qty[] = $qty; } $Pricing = array_sum($purchase_qty) >= 6 ? 'WholePrice' : 'Price'; foreach ($products as $id => $qty) { $product = new Model_Products(); $product_details = $product->ListProducts($id); $purchase[] = $product_details[$Pricing] * $qty; } $Total = array_sum($purchase); //$Products = $data['Product']; $ShippingFee = $Total < 1000 ? $data['ShippingFee'] : 0; $Total = array_sum($purchase) + $ShippingFee; $Total_qty = array_sum($purchase_qty); $member_data = array('excheckout' => $transid, 'UserID' => $UserID, 'Email' => $Email, 'Firstname' => $Firstname, 'Lastname' => $Lastname, 'Phone' => $Phone, 'ShippingAddress' => $ShippingAddress, 'DropShipAddress' => $data['DropShipAddress'], 'Region' => $data['State'], 'ShippingFee' => $ShippingFee, 'PaymentMethod' => $PaymentMethod, 'Product' => $products, 'Total' => $Total, 'PaymentDue' => $data['PaymentDue'], 'SpecialInstructions' => $data['SpecialInstructions'], 'StoreCreditsUsed' => $data['StoreCreditsUsed']); $process = $this->Add($member_data, $user_details); return $process; }
public function paynowAction() { $this->_helper->layout()->setLayout('page'); $user = $this->isLoggedIn(); if (!$user) { $this->_redirect('/login/'); } $transaction_id = $this->_getParam('TransactionID') ? $this->_getParam('TransactionID') : 0; $transactions = new Model_Transaction(); if ($transaction_id) { $data = $transactions->getUserTransaction($transaction_id, $user['SiteEmail']); } else { $this->_redirect('/myorders/'); } if (!$data) { $this->_redirect('/myorders/'); } $products = new Model_Products(); $products_data = array(); foreach ($data as $row) { $products_data[$row['ProductID']] = $products->ListProducts($row['ProductID']); } //echo '<pre>'; print_r($products_data); exit; $this->view->products_data = $products_data; $payment_exists = $transactions->getData("Payments t1", "t1.TransactionID=" . $transaction_id, "", "", "Transactions t2 on t2.ID = t1.TransactionID"); if ($payment_exists) { $this->view->payment_exists = 1; $this->view->payment_data = $payment_exists; } $rawStates = $transactions->getData("Shipping", "", "State asc"); foreach ($rawStates as $row) { $states[$row['ID']] = $row['State']; } $this->view->states = $states; $this->view->payment_methods = $this->paymentMethods(); $this->view->data = $data; $this->view->transaction_id = $transaction_id; $this->view->paynow_page = 1; }
function CategoryList($name) { $products = new Model_Products(); $data = $products->ListProducts("", $name, "", ""); return $data; }