本文整理汇总了PHP中Product::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::getAll方法的具体用法?PHP Product::getAll怎么用?PHP Product::getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product::getAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSimilarProducts
public function getSimilarProducts()
{
if ($this->similarProducts === null) {
$this->similarProducts = Product::getAll(array('category_id' => $this->category_id, 'id!=' => $this->id));
}
return $this->similarProducts;
}
示例2: indexAction
public function indexAction()
{
$this->view->Title = "Quản lý sản phẩm";
$this->view->headTitle($this->view->Title);
$page = $this->getRequest()->getParam('page');
$condition = array();
list($this->view->Pager, $this->view->Product) = Product::getAll($condition, $page);
}
示例3: index
public function index()
{
$view = new View("product/index.php");
$product = new Product();
$productAll = $product->getAll();
$view->set('productAll', $productAll);
$view->output();
}
示例4: getProductoById
public function getProductoById($id)
{
$producto = new Product();
$productos = $producto->getAll();
foreach ($productos as $prod) {
if ($prod->getId() == $id) {
return $prod;
}
}
}
示例5: testSave
function testSave()
{
$product_sku = 123456789;
$product_name = "deerhead";
$product_img = "deer.jpg";
$product_price = 99.98999999999999;
$product_paypal = 11;
$id = 1;
$new_product = new Product($product_sku, $product_name, $product_img, $product_price, $product_paypal, $id = null);
$new_product->save();
$result = Product::getAll();
$this->assertEquals($new_product, $result[0]);
}
示例6: _getData
protected static function _getData()
{
if (count(self::$_dateRange) === 0) {
$toDate = UDate::maxDate();
} else {
$toDate = self::$_dateRange['end'];
}
$return = array();
$myobCodeType = ProductCodeType::get(ProductCodeType::ID_MYOB);
foreach (Product::getAll(true) as $product) {
$logs = ProductQtyLog::getAllByCriteria('productId = ? and created <= ?', array($product->getId(), trim($toDate)), true, 1, 1, array('id' => 'desc'));
$log = count($logs) > 0 ? $logs[0] : null;
$myobCodes = ProductCode::getCodes($product, $myobCodeType, true, 1, 1);
$return[] = array('sku' => $product->getSku(), 'name' => $product->getName(), 'short description' => $product->getShortDescription(), 'category' => join(', ', array_map(create_function('$a', 'return $a->getCategory()->getName();'), $product->getCategories())), 'assetAccNo' => $product->getAssetAccNo(), 'revenueAccNo' => $product->getRevenueAccNo(), 'costAccNo' => $product->getCostAccNo(), 'Stock On PO' => $log instanceof ProductQtyLog ? $log->getStockOnPO() : $product->getStockOnPO(), 'Stock On Order' => $log instanceof ProductQtyLog ? $log->getStockOnOrder() : $product->getStockOnOrder(), 'Stock On Hand' => $log instanceof ProductQtyLog ? $log->getStockOnHand() : $product->getStockOnHand(), 'Total On Hand Value' => $log instanceof ProductQtyLog ? $log->getTotalOnHandValue() : $product->getTotalOnHandValue(), 'Stock In Parts' => $log instanceof ProductQtyLog ? $log->getStockInParts() : $product->getStockInParts(), 'Total In Parts Value' => $log instanceof ProductQtyLog ? $log->getTotalInPartsValue() : $product->getTotalInPartsValue(), 'Stock In RMA' => $log instanceof ProductQtyLog ? $log->getStockInRMA() : $product->getStockInRMA(), 'Total RMA Value' => $log instanceof ProductQtyLog ? $log->getTotalRMAValue() : $product->getTotalRMAValue(), 'active' => intval($product->getActive()) === 1 ? 'Y' : 'N', 'MYOB' => count($myobCodes) > 0 ? $myobCodes[0]->getCode() : '');
}
return $return;
}
示例7: testRegularMassDeletePagesProperlyAndRemovesAllSelected
/**
*Test Bug with mass delete and multiple pages when using select all
*/
public function testRegularMassDeletePagesProperlyAndRemovesAllSelected()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$confused = User::getByUsername('confused');
$nobody = User::getByUsername('nobody');
//Load MassDelete view for the 6 products
$products = Product::getAll();
$this->assertEquals(9, count($products));
//mass Delete pagination scenario
//Run Mass Delete using progress save for page1
$this->setGetArray(array('selectAll' => '1', 'Product_page' => 1));
$this->setPostArray(array('selectedRecordCount' => 9));
$pageSize = Yii::app()->pagination->getForCurrentUserByType('massDeleteProgressPageSize');
$this->assertEquals(5, $pageSize);
$content = $this->runControllerWithExitExceptionAndGetContent('products/default/massDelete');
$products = Product::getAll();
$this->assertEquals(4, count($products));
//Run Mass Delete using progress save for page2
$this->setGetArray(array('selectAll' => '1', 'Product_page' => 2));
$this->setPostArray(array('selectedRecordCount' => 9));
$pageSize = Yii::app()->pagination->getForCurrentUserByType('massDeleteProgressPageSize');
$this->assertEquals(5, $pageSize);
$content = $this->runControllerWithNoExceptionsAndGetContent('products/default/massDeleteProgress');
$products = Product::getAll();
$this->assertEquals(0, count($products));
}
示例8: testAsynchronousDownloadDefaultControllerActions
/**
* Walkthrough test for synchronous download
*/
public function testAsynchronousDownloadDefaultControllerActions()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$notificationsBeforeCount = Notification::getCount();
$notificationMessagesBeforeCount = NotificationMessage::getCount();
$products = Product::getAll();
if (count($products)) {
foreach ($products as $product) {
$product->delete();
}
}
$products = array();
for ($i = 0; $i <= ExportModule::$asynchronousThreshold + 1; $i++) {
$products[] = ProductTestHelper::createProductByNameForOwner('superProduct' . $i, $super);
}
$this->setGetArray(array('Product_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '1', 'selectedIds' => ''));
$this->runControllerWithRedirectExceptionAndGetUrl('products/default/export');
// Start background job
$job = new ExportJob();
$this->assertTrue($job->run());
$exportItems = ExportItem::getAll();
$this->assertEquals(1, count($exportItems));
$fileModel = $exportItems[0]->exportFileModel;
$this->assertEquals(1, $exportItems[0]->isCompleted);
$this->assertEquals('csv', $exportItems[0]->exportFileType);
$this->assertEquals('products', $exportItems[0]->exportFileName);
$this->assertTrue($fileModel instanceof ExportFileModel);
$this->assertEquals($notificationsBeforeCount + 1, Notification::getCount());
$this->assertEquals($notificationMessagesBeforeCount + 1, NotificationMessage::getCount());
// Check export job, when many ids are selected.
// This will probably never happen, but we need test for this case too.
$notificationsBeforeCount = Notification::getCount();
$notificationMessagesBeforeCount = NotificationMessage::getCount();
// Now test case when multiple ids are selected
$exportItems = ExportItem::getAll();
if (count($exportItems)) {
foreach ($exportItems as $exportItem) {
$exportItem->delete();
}
}
$selectedIds = "";
foreach ($products as $product) {
$selectedIds .= $product->id . ",";
// Not Coding Standard
}
$this->setGetArray(array('ProductsSearchForm' => array('anyMixedAttributesScope' => array(0 => 'All'), 'anyMixedAttributes' => '', 'quantity' => ''), 'multiselect_ProductsSearchForm_anyMixedAttributesScope' => 'All', 'Product_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '', 'selectedIds' => "{$selectedIds}"));
$this->runControllerWithRedirectExceptionAndGetUrl('products/default/export');
// Start background job
$job = new ExportJob();
$this->assertTrue($job->run());
$exportItems = ExportItem::getAll();
$this->assertEquals(1, count($exportItems));
$fileModel = $exportItems[0]->exportFileModel;
$this->assertEquals(1, $exportItems[0]->isCompleted);
$this->assertEquals('csv', $exportItems[0]->exportFileType);
$this->assertEquals('products', $exportItems[0]->exportFileName);
$this->assertTrue($fileModel instanceof ExportFileModel);
$this->assertEquals($notificationsBeforeCount + 1, Notification::getCount());
$this->assertEquals($notificationMessagesBeforeCount + 1, NotificationMessage::getCount());
}
示例9: function
<?php
require_once 'model/Product.php';
require_once 'model/Shoppingcart.php';
require_once 'model/Purchase.php';
// Routes
// View HTML -> Index [Home]
$app->get('/', function ($request, $response, $args) {
return $this->renderer->render($response, 'index.php', $args);
});
// REST
// Get Products
// Return array of products
$app->get('/products', function ($request, $response, $args) {
return json_encode(Product::getAll());
});
// Get Product
// Return a specific product
$app->get('/product/{id}', function ($request, $response, $args) {
return json_encode(Product::get($args['id']));
});
// Put Product
// Add product to the shopping cart
$app->put('/shoppingcart/{id}', function ($request, $response, $args) {
Shoppingcart::addProduct($args['id']);
return json_encode(Shoppingcart::countProducts());
});
// Get Shopping Cart
// Get detaills of the shopping cart
$app->get('/shoppingcart', function ($request, $response, $args) {
return json_encode(Shoppingcart::getDetaills());
示例10:
<?php
include 'configs/configs.php';
$tmp = "images/productimg/";
$newProduct = Product::getAll();
//print_r($newProduct);
$smarty->assign('tmp', $tmp);
$smarty->assign('Product', $newProduct);
$smarty->display('managerproduct.tpl');
示例11: array
/** @var Category[] $parentCategories */
$category = $c;
// помимо текущей выбранной категории, нужно отображать товары из ее дочерних категорий
$shownCategoryIds = array();
if ($category) {
$shownCategoryIds[] = $category->id;
foreach ($category->getAllChildren() as $childCategory) {
$shownCategoryIds[] = $childCategory->id;
}
}
// определяем параметры выборки товаров
$productCriteria = array();
if (count($shownCategoryIds) > 0) {
$productCriteria['category_id'] = $shownCategoryIds;
}
$products = Product::getAll($productCriteria, array('name' => true));
if ($category === null) {
$aprtData = array('pageType' => \Actionpay\APRT::PAGETYPE_MAIN);
} else {
$aprtData = array('pageType' => \Actionpay\APRT::PAGETYPE_CATALOG, 'currentCategory' => array('id' => $category->id, 'name' => $category->name), 'parentCategories' => array(), 'childCategories' => array());
foreach ($category->getAllParents() as $parentCategory) {
$aprtData['parentCategories'][] = array('id' => $parentCategory->id, 'name' => $parentCategory->name);
}
foreach ($category->getChildren() as $childCategory) {
$aprtData['childCategories'][] = array('id' => $childCategory->id, 'name' => $childCategory->name);
}
}
return $app->render('page_main', array('title' => $category ? $category->name : 'Главная', 'category' => $category, 'products' => $products, 'basket' => $app->session('basket') ?: array(), 'basketTotalItems' => $app->session('basketTotalItems') ?: 0, 'basketTotalPrice' => $app->session('basketTotalPrice') ?: 0, 'aprtData' => $aprtData));
});
/**
* Запуск приложения, вывод ответа
示例12: testSuperUserCreateFromRelationAction
public function testSuperUserCreateFromRelationAction()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$products = Product::getAll();
$productsCount = count($products);
$accountId = self::getModelIdByModelNameAndName('Account', 'superAccount');
$contactId = self::getModelIdByModelNameAndName('Contact', 'superContact superContactson');
$opportunityId = self::getModelIdByModelNameAndName('Opportunity', 'superOpportunity');
//Create a new product from a related account.
$this->setGetArray(array('relationAttributeName' => 'account', 'relationModelId' => $accountId, 'relationModuleId' => 'accounts', 'redirectUrl' => 'someRedirect'));
$currency = new Currency();
$currency->code = 'USD';
$currency->rateToBase = 1;
$currency->save();
$currencyRec = Currency::getByCode('USD');
$currencyValue1Array = array('currency' => array('id' => $currencyRec->id), 'value' => 500.54);
$product['name'] = 'myUltraNewProduct';
$product['quantity'] = 50;
$product['priceFrequency'] = ProductTemplate::PRICE_FREQUENCY_ONE_TIME;
$product['sellPrice'] = $currencyValue1Array;
$product['type'] = ProductTemplate::TYPE_PRODUCT;
$product['stage']['value'] = Product::OPEN_STAGE;
$this->setPostArray(array('Product' => $product));
$this->runControllerWithRedirectExceptionAndGetContent('products/default/createFromRelation');
$products = Product::getByName('myUltraNewProduct');
$this->assertEquals(1, count($products));
$this->assertTrue($products[0]->id > 0);
$this->assertTrue($products[0]->owner == $super);
$this->assertEquals($accountId, $products[0]->account->id);
$this->assertEquals('50', $products[0]->quantity);
$this->assertEquals('500.54', $products[0]->sellPrice->value);
$this->assertEquals(ProductTemplate::PRICE_FREQUENCY_ONE_TIME, $products[0]->priceFrequency);
$this->assertEquals(ProductTemplate::TYPE_PRODUCT, $products[0]->type);
$this->assertEquals(Product::OPEN_STAGE, $products[0]->stage->value);
$products = Product::getAll();
$this->assertEquals(++$productsCount, count($products));
//Create a new product from a related contact.
$this->setGetArray(array('relationAttributeName' => 'contact', 'relationModelId' => $contactId, 'relationModuleId' => 'contacts', 'redirectUrl' => 'someRedirect'));
$product['name'] = 'myUltraNewProduct2';
$product['quantity'] = 51;
$product['priceFrequency'] = ProductTemplate::PRICE_FREQUENCY_ANNUALLY;
$product['sellPrice'] = $currencyValue1Array;
$product['type'] = ProductTemplate::TYPE_SERVICE;
$product['stage']['value'] = Product::OPEN_STAGE;
$this->setPostArray(array('Product' => $product));
$this->runControllerWithRedirectExceptionAndGetContent('products/default/createFromRelation');
$products = Product::getByName('myUltraNewProduct2');
$this->assertEquals(1, count($products));
$this->assertTrue($products[0]->id > 0);
$this->assertTrue($products[0]->owner == $super);
$this->assertEquals($accountId, $products[0]->account->id);
$this->assertEquals($contactId, $products[0]->contact->id);
$this->assertEquals('51', $products[0]->quantity);
$this->assertEquals('500.54', $products[0]->sellPrice->value);
$this->assertEquals(ProductTemplate::PRICE_FREQUENCY_ANNUALLY, $products[0]->priceFrequency);
$this->assertEquals(ProductTemplate::TYPE_SERVICE, $products[0]->type);
$this->assertEquals(Product::OPEN_STAGE, $products[0]->stage->value);
$products = Product::getAll();
$this->assertEquals(++$productsCount, count($products));
//Create a new product from a related opportunity.
$this->setGetArray(array('relationAttributeName' => 'opportunity', 'relationModelId' => $opportunityId, 'relationModuleId' => 'opportunities', 'redirectUrl' => 'someRedirect'));
$product['name'] = 'myUltraNewProduct3';
$product['quantity'] = 51;
$product['priceFrequency'] = ProductTemplate::PRICE_FREQUENCY_ANNUALLY;
$product['sellPrice'] = $currencyValue1Array;
$product['type'] = ProductTemplate::TYPE_SERVICE;
$product['stage']['value'] = Product::OPEN_STAGE;
$this->setPostArray(array('Product' => $product));
$this->runControllerWithRedirectExceptionAndGetContent('products/default/createFromRelation');
$products = Product::getByName('myUltraNewProduct3');
$this->assertEquals(1, count($products));
$this->assertTrue($products[0]->id > 0);
$this->assertTrue($products[0]->owner == $super);
$this->assertEquals($accountId, $products[0]->account->id);
$this->assertEquals($opportunityId, $products[0]->opportunity->id);
$this->assertEquals('51', $products[0]->quantity);
$this->assertEquals('500.54', $products[0]->sellPrice->value);
$this->assertEquals(ProductTemplate::PRICE_FREQUENCY_ANNUALLY, $products[0]->priceFrequency);
$this->assertEquals(ProductTemplate::TYPE_SERVICE, $products[0]->type);
$this->assertEquals(Product::OPEN_STAGE, $products[0]->stage->value);
$products = Product::getAll();
$this->assertEquals(++$productsCount, count($products));
}
示例13: get
/**
* Return element of product as array associative
*
* @access public static
* @param integer $id ID of the product
* @return array | null
*/
public static function get($id)
{
$products = Product::getAll();
return isset($products[$id]) ? $products[$id] : null;
}
示例14: testGetAllWhenThereAreNone
public function testGetAllWhenThereAreNone()
{
Yii::app()->user->userModel = User::getByUsername('super');
$products = Product::getAll();
$this->assertEquals(1, count($products));
}
示例15: testCloningWithAnotherProduct
public function testCloningWithAnotherProduct()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
Yii::app()->user->userModel = $super;
$product = ProductTestHelper::createProductByNameForOwner("My Product 1", $super);
$id = $product->id;
$this->setGetArray(array('id' => $id));
$content = $this->runControllerWithNoExceptionsAndGetContent('products/default/copy');
$this->assertContains('My Product 1', $content);
$products = Product::getAll();
$this->assertEquals(1, count($products));
}