function listRss() { header("Content-Type: application/xml; charset=UTF-8"); $location = Url::rss(); if ($match = Uri::match('^(.*?)$')) { $location = ROOT_URL . $match[1]; $reLocation = base64_encode($location); if ($loadData = Cache::loadKey($reLocation, 60)) { $loadData = json_decode($loadData, true); return $loadData; } } $inputData = array('limitShow' => 15, 'limitPage' => 0); if ($match = Uri::match('\\/page\\/(\\d+)')) { $inputData['limitPage'] = $match[1]; } if ($match = Uri::match('\\/category\\/(\\d+)')) { $id = $match[1]; $inputData['where'] = "where catid='{$id}'"; } if ($match = Uri::match('rss\\/products')) { $loadData = Products::get($inputData); } else { $loadData = Post::get($inputData); } $reLocation = base64_encode($location); Cache::saveKey($reLocation, json_encode($loadData)); return $loadData; }
/** * Index lists all the products * * @param SS_HTTPRequest $request * @return PaginatedList */ public function index(SS_HTTPRequest $request) { $transaction = Session::get("transaction"); // clear old session data if (!empty($transaction)) { Session::clear("transaction"); Session::clear("order"); } $filter = array('Active' => true); $searchQuery = $request->getVar('search'); if ($searchQuery) { $filter['ProductDescription:PartialMatch'] = $searchQuery; } $produts = Products::get()->filter($filter); $paginatedProducts = PaginatedList::create($produts, $request); $paginatedProducts->setPageLength(10); $total = $this->total(); return array('Products' => $paginatedProducts, 'searchQuery' => $searchQuery, 'CartItems' => $this->CartItems(), 'CartItemsCount' => $this->CartItemsCount(), 'CartTotal' => $total["total"], 'ShippingTotal' => $total["shippingtotal"]); }
public function toString() { $p = Products::get($this->product_slug); $s = $p->name . " "; foreach ($this->options as $o) { $s .= "(" . $o . ") "; } if ($this->qty > 1) { $s .= " @ \$" . $p->val($this->qty, $this->options) . " x" . $this->qty . " "; } $s .= "= \$" . $this->subtotal() . "\n"; $shipping = $this->shippingCost(); if ($shipping > 0) { $s .= "+ \$" . $shipping . " shipping\n"; } return $s; }