本文整理汇总了PHP中PrestaShopCollection类的典型用法代码示例。如果您正苦于以下问题:PHP PrestaShopCollection类的具体用法?PHP PrestaShopCollection怎么用?PHP PrestaShopCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PrestaShopCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: getShopGroups
public static function getShopGroups($active = true)
{
$groups = new PrestaShopCollection('ShopGroup');
$groups->where('deleted', '=', false);
if ($active) {
$groups->where('active', '=', true);
}
return $groups;
}
示例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: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: getCollectionFromModule
/**
* Get collection from module name
* @static
* @param $module string Module name
* @param null $id_lang integer Language ID
* @return array|Collection Collection of tabs (or empty array)
*/
public static function getCollectionFromModule($module, $id_lang = null)
{
if (is_null($id_lang)) {
$id_lang = Context::getContext()->language->id;
}
if (!Validate::isModuleName($module)) {
return array();
}
$tabs = new PrestaShopCollection('Tab', (int) $id_lang);
$tabs->where('module', '=', $module);
return $tabs;
}
示例10: assignOrderTracking
/**
* Assigns template vars related to order tracking information
*
* @param PrestaShopCollection $order_collection
*
* @throws PrestaShopException
*/
protected function assignOrderTracking($order_collection)
{
$customer = new Customer((int) $order_collection->getFirst()->id_customer);
$order_collection = $order_collection->getAll();
$order_list = array();
foreach ($order_collection as $order) {
$order_list[] = $order;
}
foreach ($order_list as &$order) {
/** @var Order $order */
$order->id_order_state = (int) $order->getCurrentState();
$order->invoice = OrderState::invoiceAvailable((int) $order->id_order_state) && $order->invoice_number;
$order->order_history = $order->getHistory((int) $this->context->language->id, false, true);
$order->carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang);
$order->address_invoice = new Address((int) $order->id_address_invoice);
$order->address_delivery = new Address((int) $order->id_address_delivery);
$order->inv_adr_fields = AddressFormat::getOrderedAddressFields($order->address_invoice->id_country);
$order->dlv_adr_fields = AddressFormat::getOrderedAddressFields($order->address_delivery->id_country);
$order->invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($order->address_invoice, $order->inv_adr_fields);
$order->deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($order->address_delivery, $order->dlv_adr_fields);
$order->currency = new Currency($order->id_currency);
$order->discounts = $order->getCartRules();
$order->invoiceState = Validate::isLoadedObject($order->address_invoice) && $order->address_invoice->id_state ? new State((int) $order->address_invoice->id_state) : false;
$order->deliveryState = Validate::isLoadedObject($order->address_delivery) && $order->address_delivery->id_state ? new State((int) $order->address_delivery->id_state) : false;
$order->products = $order->getProducts();
$order->customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
Product::addCustomizationPrice($order->products, $order->customizedDatas);
$order->total_old = $order->total_discounts > 0 ? (double) $order->total_paid - (double) $order->total_discounts : false;
if ($order->carrier->url && $order->shipping_number) {
$order->followup = str_replace('@', $order->shipping_number, $order->carrier->url);
}
$order->hook_orderdetaildisplayed = Hook::exec('displayOrderDetail', array('order' => $order));
Hook::exec('actionOrderDetail', array('carrier' => $order->carrier, 'order' => $order));
}
$this->context->smarty->assign(array('shop_name' => Configuration::get('PS_SHOP_NAME'), 'order_collection' => $order_list, 'return_allowed' => false, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'is_guest' => true, 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'use_tax' => Configuration::get('PS_TAX')));
}
示例11: 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;
}
示例12: 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;
}
示例13: 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();
}
}
}
示例14: 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;
}
示例15: 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;
}