本文整理汇总了PHP中Catalog::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP Catalog::getById方法的具体用法?PHP Catalog::getById怎么用?PHP Catalog::getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Catalog
的用法示例。
在下文中一共展示了Catalog::getById方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: one
public function one()
{
//положить в корзину AJAX
if ($this->post['trash'] == 'add') {
$id = $this->post['id'];
$this->show->trash[$id]['id'] = $id;
$this->show->trash[$id]['col'] = 1;
$this->session->set('trash', $this->show->trash);
exit('ok');
}
$oCatalog = new Catalog();
$this->show->item = $oCatalog->getById($this->show->itemID);
$this->show->breadcrumbs[] = array('PageURL' => BASE_PATH . 'catalog/' . $this->show->item['ItemID'], 'Title' => $this->show->item['Title']);
$this->show->categoryID = $this->show->item['CategoryID'];
$this->template->action = 'one';
}
示例2: index
public function index()
{
$this->show['Title'] = 'Ваша корзина';
$trash = $this->show->trash;
if (sizeof($trash) < 1) {
$this->show['Title'] = 'Ваша корзина пуста...';
} else {
$this->show->basketList = array();
$catalog = new Catalog();
foreach ($trash as $i => $row) {
$str = $catalog->getById($row['id']);
$str['col'] = $row['col'];
$this->show->basketList[$i] = $str;
$this->show->basketList[$i]['col'] = $row['col'];
}
}
if (isset($_POST['basket']) && $_POST['basket'] == 'del') {
if (array_key_exists($_POST['id'], $this->show->basketList)) {
unset($this->show->basketList[$_POST['id']]);
unset($trash[$_POST['id']]);
$this->session->set('trash', $trash);
if (sizeof($trash) == 0) {
$this->session->delete('trash');
exit('0');
}
exit("'" . sizeof($trash) . "'");
} else {
exit('error');
}
}
if (isset($_POST['basket']) && $_POST['basket'] == 'save') {
$trash = NULL;
foreach ($_POST['trash'] as $key => $val) {
$row = explode('/', $val);
$trash[$key]['id'] = $key;
$trash[$key]['col'] = $row[1];
}
$this->session->set('trash', $trash);
exit('ok');
}
}
示例3: edit
public function edit()
{
$oCatalog = new Catalog();
$prop = new Catalog_Property();
if ($this->show->itemID) {
$row = $oCatalog->getById($this->show->itemID);
$this->show->categoryID = $row['CategoryID'];
$this->show->propertyID = $row['PropertyID'];
} else {
$this->show->brandID = $this->post['BrandID'];
$this->show->categoryID = $this->post['CategoryID'];
}
$this->show->propertyList = $prop->getList($this->show->categoryID);
setcookie("brandID", $this->show->brandID, null, '/');
$this->show->status = $oCatalog->getStatusList();
if (!empty($this->post['Save'])) {
if ($this->show->itemID) {
$oCatalogID = $oCatalog->update($this->post, $this->show->itemID);
} else {
$oCatalogID = $oCatalog->insert($this->post);
}
if ($oCatalogID) {
redirect(BASE_PATH . 'admin/catalog/');
}
}
if ($this->show->itemID) {
$this->show->item = $oCatalog->getByID($this->show->itemID);
$this->show->breadcrumbs[] = array('url' => BASE_PATH . 'admin/catalog/' . $this->show->itemID, 'title' => $this->show->item['Title']);
} else {
$this->show->item = $oCatalog->get();
$this->show->breadcrumbs[] = array('url' => BASE_PATH . 'admin/catalog/' . $this->show->itemID, 'title' => 'Создание');
$oCategory = new Catalog_Category();
$this->show->categoryList = $oCategory->getList($this->show->brandID);
$oBrand = new Catalog_Brand();
$this->show->brandList = $oBrand->getList();
}
if (!empty($this->post['Save'])) {
$this->show->item->merge($this->post);
}
}
示例4: index
public function index()
{
$this->show['Title'] = 'Оформление заказа';
$this->session = MySession::getInstance();
$trash = $this->session->get('trash');
if (sizeof($trash) < 1) {
$this->show['Title'] = 'Ваша корзина пуста...';
} else {
$this->show->basketList = array();
$catalog = new Catalog();
foreach ($trash as $i => $item) {
$str = $catalog->getById($item['id']);
$str['col'] = $item['col'];
$this->show->basketList[$i] = $str;
$this->show->basketList[$i]['col'] = $item['col'];
}
}
if (isset($_POST['mode']) && $_POST['mode'] == 'send') {
$db = MySQL::getInstance();
$db->query('SELECT FieldName, FieldValue FROM `config` WHERE FieldName="Title"');
$str = $db->fetchRow();
$sitename = $str['FieldValue'];
if (substr(PHP_OS, 0, 3) == "WIN") {
$n = "\r\n";
} else {
$n = "\n";
}
$mail = htmlspecialchars(stripslashes(trim($_POST['mail'])));
$name = htmlspecialchars(stripslashes(trim($_POST['name'])));
$phone = htmlspecialchars(stripslashes(trim($_POST['phone'])));
$description = htmlspecialchars(stripslashes(trim($_POST['description'])));
$body = 'Заказ с сайта ' . $sitename . $n;
$body .= 'тел:' . $phone . ' ' . $name . $n . $n;
$w = array('n' => 4, 'cod' => 15, 'name' => 30, 'x' => 20);
$row = 1;
$total = 0;
foreach ($this->show->basketList as $key => $val) {
$body .= str_pad($row, $w['n'], " ", STR_PAD_RIGHT);
$body .= str_pad($val['Code'], $w['cod'], " ", STR_PAD_RIGHT);
$body .= str_pad($val['Title'], $w['name'], " ", STR_PAD_RIGHT) . $n . $n;
$body .= str_pad(' ', $w['n'], " ", STR_PAD_RIGHT);
$body .= str_pad('Цена ', $w['x'], " ", STR_PAD_RIGHT) . $val['Price'] . " руб." . $n;
$body .= str_pad(' ', $w['n'], " ", STR_PAD_RIGHT);
$body .= str_pad('Кол-во ', $w['x'], " ", STR_PAD_RIGHT) . $val['col'] . ' ' . $val['Ed'] . $n;
$body .= str_pad(' ', $w['n'], " ", STR_PAD_RIGHT);
$body .= str_pad('Сумма ', $w['x'], " ", STR_PAD_RIGHT) . $val['col'] * $val['Price'] . ' руб.' . $n;
$total += $val['col'] * $val['Price'];
$row++;
$body .= $n . str_pad('_', 60, "_", STR_PAD_RIGHT) . $n;
}
$body .= $n . ' ИТОГО на сумму: ' . $total . ' руб.' . $n . $n . $n;
$body .= $description;
$to = [$this->show->Email];
$subject = 'Заказ с сайта ' . $sitename . '--' . $mail;
$transport = Swift_SmtpTransport::newInstance($this->show->Smtp, $this->show->Port, "ssl")->setUsername($this->show->Login)->setPassword($this->show->Password);
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance($subject)->setFrom(array($this->show->Email))->setTo($to)->setBody($body);
$result = $mailer->send($message);
if ($result == 1) {
$trash = null;
$this->session->delete('trash');
$this->show->basketList = null;
exit('ok');
}
exit('error');
}
}