本文整理汇总了PHP中Products::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Products::getAll方法的具体用法?PHP Products::getAll怎么用?PHP Products::getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products
的用法示例。
在下文中一共展示了Products::getAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: productsAction
public function productsAction()
{
$ns = new Zend_Session_Namespace();
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><shineisp></shineisp>');
$localeID = $ns->idlang;
$products = $xml->addChild('products');
try {
// Get all the products
$records = Products::getAll(null, $localeID);
if (!empty($records)) {
foreach ($records as $item) {
$item['ProductsData'][0]['shortdescription'] = strip_tags($item['ProductsData'][0]['shortdescription']);
$item['ProductsData'][0]['description'] = strip_tags($item['ProductsData'][0]['description']);
$item['ProductsData'][0]['shortdescription'] = html_entity_decode($item['ProductsData'][0]['shortdescription'], ENT_NOQUOTES, "UTF-8");
$item['ProductsData'][0]['description'] = html_entity_decode($item['ProductsData'][0]['description'], ENT_NOQUOTES, "UTF-8");
$item['ProductsData'][0]['shortdescription'] = str_replace("&", "", $item['ProductsData'][0]['shortdescription']);
$item['ProductsData'][0]['description'] = str_replace("&", "", $item['ProductsData'][0]['description']);
$categories = products::get_text_categories($item['categories']);
$categories = htmlspecialchars($categories);
$product = $products->addChild('product');
$product->addAttribute('uuid', $item['uuid']);
$product->addAttribute('id', $item['product_id']);
$product->addAttribute('inserted_at', !empty($item['inserted_at']) ? strtotime($item['inserted_at']) : null);
$product->addAttribute('updated_at', !empty($item['updated_at']) ? strtotime($item['updated_at']) : null);
$product->addChild('sku', htmlentities($item['sku']));
if (!empty($item['ProductsMedia'][0]['path']) && file_exists(PUBLIC_PATH . $item['ProductsMedia'][0]['path'])) {
$product->addChild('image', "http://" . $_SERVER['HTTP_HOST'] . $item['ProductsMedia'][0]['path']);
}
$product->addChild('name', !empty($item['ProductsData'][0]['name']) ? $item['ProductsData'][0]['name'] : null);
$product->addChild('shortdescription', !empty($item['ProductsData'][0]['shortdescription']) ? "<![CDATA[" . $item['ProductsData'][0]['shortdescription'] . "]]>" : null);
$product->addChild('description', !empty($item['ProductsData'][0]['description']) ? "<![CDATA[" . $item['ProductsData'][0]['description'] . "]]>" : null);
$product->addChild('categories', $categories);
$price = $product->addChild('price', Products::getPrice($item['product_id']));
$price->addAttribute('taxincluded', 0);
$price->addAttribute('isrecurrent', products::isRecurring($item['product_id']));
$price->addAttribute('currency', Settings::findbyParam('currency'));
}
}
header('Content-Type: text/xml; charset=utf-8');
die($xml->asXML());
} catch (Exception $e) {
Shineisp_Commons_Utilities::log(__CLASS__ . " " . $e->getMessage());
die;
}
}
示例2: getByCategoryName
/**
* retrieve products by their category name
*
* @param string $name name of the category
* @param int $enabledFilter whether to allow enabled/disabled products
*
* @return object instance of Products object
*/
static function getByCategoryName($name, $enabledFilter = 0, $noRecurse = 0)
{
$arr = explode('/', $name);
if ($arr[0] == '') {
array_shift($arr);
}
$cid = 0;
foreach ($arr as $name) {
$cid = dbOne('select id from products_categories where parent_id=' . $cid . ' and name="' . addslashes($name) . '" limit 1', 'id', 'products_categories');
if (!$cid) {
break;
}
}
if (!$cid) {
return Products::getAll('', 0, $enabledFilter);
}
return Products::getByCategory($cid, array(), '_name', 'asc', 0, $noRecurse);
}
示例3: searchAction
/**
* Search the record for the Select2 JQuery Object by ajax
* @return json
*/
public function searchAction()
{
if ($this->getRequest()->isXmlHttpRequest()) {
$term = $this->getParam('term');
$id = $this->getParam('id');
if (!empty($term)) {
$term = "%{$term}%";
$records = Products::findbyName($term, "product_id, pd.name as name", true);
die(json_encode($records));
}
if (!empty($id)) {
$records = Products::find($id);
die(json_encode($records));
}
$records = Products::getAll('product_id, pd.name as name');
die(json_encode($records));
} else {
die;
}
}