本文整理汇总了PHP中PrestaShopCollection::where方法的典型用法代码示例。如果您正苦于以下问题:PHP PrestaShopCollection::where方法的具体用法?PHP PrestaShopCollection::where怎么用?PHP PrestaShopCollection::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PrestaShopCollection
的用法示例。
在下文中一共展示了PrestaShopCollection::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getShopGroups
public static function getShopGroups($active = true)
{
$groups = new PrestaShopCollection('ShopGroup');
$groups->where('deleted', '=', false);
if ($active) {
$groups->where('active', '=', true);
}
return $groups;
}
示例2: getShopUrls
/**
* Get list of shop urls
*
* @param bool $id_shop
* @return PrestaShopCollection Collection of ShopUrl
*/
public static function getShopUrls($id_shop = false)
{
$urls = new PrestaShopCollection('ShopUrl');
if ($id_shop) {
$urls->where('id_shop', '=', $id_shop);
}
return $urls;
}
示例3: getAllThemes
public static function getAllThemes($excluded_ids = false)
{
$themes = new PrestaShopCollection('Theme');
if (is_array($excluded_ids) && !empty($excluded_ids)) {
$themes->where('id_theme', 'notin', $excluded_ids);
}
$themes->orderBy('name');
return $themes;
}
示例4: getByInvoiceId
/**
* Get Order Payments By Invoice ID
*
* @param int $id_invoice Invoice ID
* @return PrestaShopCollection Collection of OrderPayment
*/
public static function getByInvoiceId($id_invoice)
{
$payments = Db::getInstance()->executeS('SELECT id_order_payment FROM `' . _DB_PREFIX_ . 'order_invoice_payment` WHERE id_order_invoice = ' . (int) $id_invoice);
if (!$payments) {
return array();
}
$payment_list = array();
foreach ($payments as $payment) {
$payment_list[] = $payment['id_order_payment'];
}
$payments = new PrestaShopCollection('OrderPayment');
$payments->where('id_order_payment', 'IN', $payment_list);
return $payments;
}
示例5: getEntriesCollection
/**
* Retrieves the details entries (i.e. products) collection for the current order
*
* @return PrestaShopCollection Collection of SupplyOrderDetail
*/
public function getEntriesCollection()
{
$details = new PrestaShopCollection('SupplyOrderDetail');
$details->where('id_supply_order', '=', $this->id);
return $details;
}
示例6: getShopsCollection
/**
* Get a collection of shops
*
* @param bool $active
* @param int $id_shop_group
* @return PrestaShopCollection Collection of Shop
*/
public static function getShopsCollection($active = true, $id_shop_group = null)
{
$shops = new PrestaShopCollection('Shop');
if ($active) {
$shops->where('active', '=', 1);
}
if ($id_shop_group) {
$shops->where('id_shop_group', '=', (int) $id_shop_group);
}
return $shops;
}
示例7: getSibling
/**
* Return collection of order invoice object linked to the payments of the current order invoice object
*
* @since 1.5.0.14
* @return PrestaShopCollection|array Collection of OrderInvoice or empty array
*/
public function getSibling()
{
$query = new DbQuery();
$query->select('oip2.id_order_invoice');
$query->from('order_invoice_payment', 'oip1');
$query->innerJoin('order_invoice_payment', 'oip2', 'oip2.id_order_payment = oip1.id_order_payment AND oip2.id_order_invoice <> oip1.id_order_invoice');
$query->where('oip1.id_order_invoice = ' . $this->id);
$invoices = Db::getInstance()->executeS($query);
if (!$invoices) {
return array();
}
$invoice_list = array();
foreach ($invoices as $invoice) {
$invoice_list[] = $invoice['id_order_invoice'];
}
$payments = new PrestaShopCollection('OrderInvoice');
$payments->where('id_order_invoice', 'IN', $invoice_list);
return $payments;
}
示例8: getBrother
/**
* Get all other orders with the same reference
*
* @since 1.5.0.13
*/
public function getBrother()
{
$collection = new PrestaShopCollection('order');
$collection->where('reference', '=', $this->reference);
$collection->where('id_order', '<>', $this->id);
return $collection;
}
示例9: getAllParents
/**
* Return an array of all parents of the current category
*
* @param int $id_lang
* @return PrestaShopCollection Collection of Category
*/
public function getAllParents($id_lang = null)
{
if (is_null($id_lang)) {
$id_lang = Context::getContext()->language->id;
}
$categories = new PrestaShopCollection('Category', $id_lang);
$categories->where('nleft', '<', $this->nleft);
$categories->where('nright', '>', $this->nright);
return $categories;
}
示例10: getCollection
/**
* For a given product, gets its warehouses
*
* @param int $id_product
* @return PrestaShopCollection The type of the collection is WarehouseProductLocation
*/
public static function getCollection($id_product)
{
$collection = new PrestaShopCollection('WarehouseProductLocation');
$collection->where('id_product', '=', (int) $id_product);
return $collection;
}
示例11: deleteByIdCustomer
/**
* @static
* @param $id_customer
* @return bool
*/
public static function deleteByIdCustomer($id_customer)
{
$return = true;
$cart_rules = new PrestaShopCollection('CartRule');
$cart_rules->where('id_customer', '=', $id_customer);
foreach ($cart_rules as $cart_rule) {
$return &= $cart_rule->delete();
}
return $return;
}
示例12: renderCSV
/**
* Exports CSV
*/
protected function renderCSV()
{
// exports orders
if (Tools::isSubmit('csv_orders')) {
$ids = array();
foreach ($this->_list as $entry) {
$ids[] = $entry['id_supply_order'];
}
if (count($ids) <= 0) {
return;
}
$id_lang = Context::getContext()->language->id;
$orders = new PrestaShopCollection('SupplyOrder', $id_lang);
$orders->where('is_template', '=', false);
$orders->where('id_supply_order', 'in', $ids);
$id_warehouse = $this->getCurrentWarehouse();
if ($id_warehouse != -1) {
$orders->where('id_warehouse', '=', $id_warehouse);
}
$orders->getAll();
$csv = new CSV($orders, $this->l('supply_orders'));
$csv->export();
} elseif (Tools::isSubmit('csv_orders_details')) {
// header
header('Content-type: text/csv');
header('Content-Type: application/force-download; charset=UTF-8');
header('Cache-Control: no-store, no-cache');
header('Content-disposition: attachment; filename="' . $this->l('supply_orders_details') . '.csv"');
// echoes details
$ids = array();
foreach ($this->_list as $entry) {
$ids[] = $entry['id_supply_order'];
}
if (count($ids) <= 0) {
return;
}
// for each supply order
$keys = array('id_product', 'id_product_attribute', 'reference', 'supplier_reference', 'ean13', 'upc', 'name', 'unit_price_te', 'quantity_expected', 'quantity_received', 'price_te', 'discount_rate', 'discount_value_te', 'price_with_discount_te', 'tax_rate', 'tax_value', 'price_ti', 'tax_value_with_order_discount', 'price_with_order_discount_te', 'id_supply_order');
echo sprintf("%s\n", implode(';', array_map(array('CSVCore', 'wrap'), $keys)));
// overrides keys (in order to add FORMAT calls)
$keys = array('sod.id_product', 'sod.id_product_attribute', 'sod.reference', 'sod.supplier_reference', 'sod.ean13', 'sod.upc', 'sod.name', 'FORMAT(sod.unit_price_te, 2)', 'sod.quantity_expected', 'sod.quantity_received', 'FORMAT(sod.price_te, 2)', 'FORMAT(sod.discount_rate, 2)', 'FORMAT(sod.discount_value_te, 2)', 'FORMAT(sod.price_with_discount_te, 2)', 'FORMAT(sod.tax_rate, 2)', 'FORMAT(sod.tax_value, 2)', 'FORMAT(sod.price_ti, 2)', 'FORMAT(sod.tax_value_with_order_discount, 2)', 'FORMAT(sod.price_with_order_discount_te, 2)', 'sod.id_supply_order');
foreach ($ids as $id) {
$query = new DbQuery();
$query->select(implode(', ', $keys));
$query->from('supply_order_detail', 'sod');
$query->leftJoin('supply_order', 'so', 'so.id_supply_order = sod.id_supply_order');
$id_warehouse = $this->getCurrentWarehouse();
if ($id_warehouse != -1) {
$query->where('so.id_warehouse = ' . (int) $id_warehouse);
}
$query->where('sod.id_supply_order = ' . (int) $id);
$query->orderBy('sod.id_supply_order_detail DESC');
$resource = Db::getInstance()->query($query);
// gets details
while ($row = Db::getInstance()->nextRow($resource)) {
echo sprintf("%s\n", implode(';', array_map(array('CSVCore', 'wrap'), $row)));
}
}
} elseif (Tools::isSubmit('csv_order_details') && Tools::getValue('id_supply_order')) {
$supply_order = new SupplyOrder((int) Tools::getValue('id_supply_order'));
if (Validate::isLoadedObject($supply_order)) {
$details = $supply_order->getEntriesCollection();
$details->getAll();
$csv = new CSV($details, $this->l('supply_order') . '_' . $supply_order->reference . '_details');
$csv->export();
}
}
}
示例13: deleteDownload
/**
* Remove all downloadable files for product and its attributes
*
* @return bool
*/
public function deleteDownload()
{
$result = true;
$collection_download = new PrestaShopCollection('ProductDownload');
$collection_download->where('id_product', '=', $this->id);
foreach ($collection_download as $product_download) {
/** @var ProductDownload $product_download */
$result &= $product_download->delete($product_download->checkFile());
}
return $result;
}
示例14: getSupplierCollection
/**
* For a given product, retrieves its suppliers
*
* @param int $id_product
* @param int $group_by_supplier
* @return Collection
*/
public static function getSupplierCollection($id_product, $group_by_supplier = true)
{
$suppliers = new PrestaShopCollection('ProductSupplier');
$suppliers->where('id_product', '=', (int) $id_product);
if ($group_by_supplier) {
$suppliers->groupBy('id_supplier');
}
return $suppliers;
}
示例15: getStockCollection
/**
* For a given product, retrieves the stock collection
*
* @param int $id_product
* @param int $id_product_attribute
* @param int $id_warehouse Optional
* @param int $price_te Optional
* @return PrestaShopCollection Collection of Stock
*/
protected function getStockCollection($id_product, $id_product_attribute, $id_warehouse = null, $price_te = null)
{
$stocks = new PrestaShopCollection('Stock');
$stocks->where('id_product', '=', $id_product);
$stocks->where('id_product_attribute', '=', $id_product_attribute);
if ($id_warehouse) {
$stocks->where('id_warehouse', '=', $id_warehouse);
}
if ($price_te) {
$stocks->where('price_te', '=', $price_te);
}
return $stocks;
}