本文整理汇总了PHP中DbQuery::innerJoin方法的典型用法代码示例。如果您正苦于以下问题:PHP DbQuery::innerJoin方法的具体用法?PHP DbQuery::innerJoin怎么用?PHP DbQuery::innerJoin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbQuery
的用法示例。
在下文中一共展示了DbQuery::innerJoin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getProductName
/**
* Gets the name of a given product, in the given lang
* HAI : override method to record product name with sort
*
* @since 1.5.0
* @param int $id_product
* @param int $id_product_attribute Optional
* @param int $id_lang Optional
* @return string
*/
public static function getProductName($id_product, $id_product_attribute = null, $id_lang = null)
{
// use the lang in the context if $id_lang is not defined
if (!$id_lang) {
$id_lang = (int) Context::getContext()->language->id;
}
// creates the query object
$query = new DbQuery();
// selects different names, if it is a combination
if ($id_product_attribute) {
$query->select('IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(DISTINCT agl.`name`, \' - \', al.name ORDER BY agl.`name`, \' - \', al.name ASC SEPARATOR \', \')),pl.name) as name');
} else {
$query->select('DISTINCT pl.name as name');
}
// adds joins & where clauses for combinations
if ($id_product_attribute) {
$query->from('product_attribute', 'pa');
$query->join(Shop::addSqlAssociation('product_attribute', 'pa'));
$query->innerJoin('product_lang', 'pl', 'pl.id_product = pa.id_product AND pl.id_lang = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl'));
$query->leftJoin('product_attribute_combination', 'pac', 'pac.id_product_attribute = pa.id_product_attribute');
$query->leftJoin('attribute', 'atr', 'atr.id_attribute = pac.id_attribute');
$query->leftJoin('attribute_lang', 'al', 'al.id_attribute = atr.id_attribute AND al.id_lang = ' . (int) $id_lang);
$query->leftJoin('attribute_group_lang', 'agl', 'agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = ' . (int) $id_lang);
$query->where('pa.id_product = ' . (int) $id_product . ' AND pa.id_product_attribute = ' . (int) $id_product_attribute);
} else {
$query->from('product_lang', 'pl');
$query->where('pl.id_product = ' . (int) $id_product);
$query->where('pl.id_lang = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl'));
}
return Db::getInstance()->getValue($query);
}
示例2: getAll
/**
* Launch sql query to create collection of objects
*
* @param bool $display_query If true, query will be displayed (for debug purpose)
* @return PrestaShopCollection
*/
public function getAll($display_query = false)
{
if ($this->is_hydrated) {
return $this;
}
$this->is_hydrated = true;
$alias = $this->generateAlias();
//$this->query->select($alias.'.*');
$this->query->from($this->definition['table'], $alias);
// If multilang, create association to lang table
if (!empty($this->definition['multilang'])) {
$this->join(self::LANG_ALIAS);
if ($this->id_lang) {
$this->where(self::LANG_ALIAS . '.id_lang', '=', $this->id_lang);
}
}
// Add join clause
foreach ($this->join_list as $data) {
$on = '(' . implode(') AND (', $data['on']) . ')';
switch ($data['type']) {
case self::LEFT_JOIN:
$this->query->leftJoin($data['table'], $data['alias'], $on);
break;
case self::INNER_JOIN:
$this->query->innerJoin($data['table'], $data['alias'], $on);
break;
case self::LEFT_OUTER_JOIN:
$this->query->leftOuterJoin($data['table'], $data['alias'], $on);
break;
}
}
// All limit clause
if ($this->page_size) {
$this->query->limit($this->page_size, $this->page_number * $this->page_size);
}
// Shall we display query for debug ?
if ($display_query) {
echo $this->query . '<br />';
}
$this->results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query);
if ($this->results && is_array($this->results)) {
$this->results = ObjectModel::hydrateCollection($this->classname, $this->results, $this->id_lang);
}
return $this;
}
示例3: getMenuItems
/**
* Returns all menu items for a given shop
*
* @param int $id_lang
* @param int $id_shop
*
* @return array
*/
public static function getMenuItems($id_lang, $id_shop)
{
$sql = new DbQuery();
$sql->select('i.*, il.url, il.title, il.name');
$sql->from('ct_top_menu_item', 'i');
$sql->leftJoin('ct_top_menu_item_lang', 'il', 'i.id_ct_top_menu_item = il.id_ct_top_menu_item AND il.id_lang = ' . (int) $id_lang);
$sql->innerJoin('ct_top_menu_item_shop', 'ishop', 'i.id_ct_top_menu_item = ishop.id_ct_top_menu_item AND ishop.id_shop = ' . (int) $id_shop);
$sql->orderBy('ishop.position ASC');
return (array) Db::getInstance()->executeS($sql);
}
示例4: getAbandonedCartInfo
private function getAbandonedCartInfo()
{
if ((int) $this->cart_id < 1) {
return false;
}
$query_limit = 0;
$query_offset = 0;
$cart_products = array();
if ($this->page !== null && !empty($this->page) && $this->show !== null && !empty($this->show)) {
$query_limit = ((int) $this->page - 1) * (int) $this->show;
$query_offset = (int) $this->show;
}
// Get cart information
$cart_info_obj = new DbQuery();
$cart_info_obj->select("\r\n\t\t\tc.id_cart,\r\n\t\t\tc.date_add,\r\n\t\t\tc.id_currency,\r\n\t\t\tc.id_customer,\r\n\t\t\tcus.date_add AS account_registered,\r\n\t\t\tcus.email,\r\n\t\t\ta.phone,\r\n\t\t\tCONCAT(cus.firstname, ' ', cus.lastname) AS customer,\r\n\t\t\ts.name AS shop_name,\r\n\t\t\tcar.name AS carrier_name,\r\n\t\t\tSUM((ps.price + pas.price) * cp.quantity) AS cart_total\r\n\t\t");
$cart_info_obj->from('cart', 'c');
$cart_info_obj->innerJoin('cart_product', 'cp', 'cp.id_cart = c.id_cart');
$cart_info_obj->leftJoin('product_shop', 'ps', 'ps.id_product = cp.id_product AND ps.id_shop = cp.id_shop');
$cart_info_obj->leftJoin('product_attribute_shop', 'pas', 'pas.id_product_attribute = cp.id_product_attribute AND pas.id_shop = cp.id_shop');
$cart_info_obj->leftJoin('customer', 'cus', 'c.id_customer = cus.id_customer');
$cart_info_obj->leftJoin('address', 'a', 'a.id_customer = cus.id_customer');
$cart_info_obj->leftJoin('shop', 's', 's.id_shop = c.id_shop');
$cart_info_obj->leftJoin('carrier', 'car', 'car.id_carrier = c.id_carrier');
$cart_info_obj->where('c.id_cart = ' . (int) $this->cart_id);
$cart_info_obj->groupBy('c.id_cart');
$cart_info_sql = $cart_info_obj->build();
$cart_info = Db::getInstance()->executeS($cart_info_sql);
$cart_info = array_shift($cart_info);
if (trim($cart_info['customer']) == '') {
$cart_info['customer'] = self::GUEST;
}
// Convert and format price data
if ($this->currency_code != $cart_info['id_currency']) {
$cart_info['cart_total'] = $this->convertPrice($cart_info['cart_total'], $this->def_currency, $cart_info['id_currency']);
}
$cart_info['cart_total'] = $this->displayPrice($cart_info['cart_total'], $cart_info['id_currency']);
// Get cart products
$cart_products_obj = new DbQuery();
$cart_products_obj->select('
cp.id_product,
cp.id_product_attribute,
cp.quantity AS product_quantity,
p.reference AS sku,
(ps.price + pas.price) AS product_price,
(ps.wholesale_price + pas.wholesale_price) AS wholesale_price,
c.id_currency,
pl.name AS product_name,
pl.link_rewrite
');
$cart_products_obj->from('cart_product', 'cp');
$cart_products_obj->leftJoin('product_shop', 'ps', 'ps.id_product = cp.id_product AND ps.id_shop = cp.id_shop');
$cart_products_obj->leftJoin('product_attribute_shop', 'pas', 'pas.id_product_attribute = cp.id_product_attribute AND pas.id_shop = cp.id_shop');
$cart_products_obj->leftJoin('product', 'p', 'p.id_product = cp.id_product');
$cart_products_obj->leftJoin('cart', 'c', 'c.id_cart = cp.id_cart');
$cart_products_obj->leftJoin('product_lang', 'pl', 'pl.id_product = cp.id_product AND pl.id_shop = cp.id_shop AND pl.id_lang = ' . (int) $this->def_lang);
$cart_products_obj->where('cp.id_cart = ' . (int) $this->cart_id);
$cart_products_obj->limit($query_offset, $query_limit);
$cart_products_sql = $cart_products_obj->build();
$cart_products_res = Db::getInstance()->executeS($cart_products_sql);
// Get attribute values
foreach ($cart_products_res as $product) {
$product_attributes_obj = new DbQuery();
$product_attributes_obj->select('
al.name AS attribute_value,
agl.public_name AS attribute_name
');
$product_attributes_obj->from('product_attribute_combination', 'pac');
$product_attributes_obj->leftJoin('attribute_lang', 'al', 'al.id_attribute = pac.id_attribute AND al.id_lang = ' . (int) $this->def_lang);
$product_attributes_obj->leftJoin('attribute', 'a', 'a.id_attribute = pac.id_attribute');
$product_attributes_obj->leftJoin('attribute_group_lang', 'agl', 'agl.id_attribute_group = a.id_attribute_group AND agl.id_lang = ' . (int) $this->def_lang);
$product_attributes_obj->where('pac.id_product_attribute = ' . (int) $product['id_product_attribute']);
$product_attributes_obj->orderBy('attribute_name');
$product_attributes_sql = $product_attributes_obj->build();
$product_attributes = Db::getInstance()->executeS($product_attributes_sql);
$product_attr = array();
foreach ($product_attributes as $product_attribute) {
$product_attr[] = $product_attribute['attribute_name'] . ' : ' . $product_attribute['attribute_value'];
}
$product['combination'] = !empty($product_attr) ? implode(', ', $product_attr) : '';
// Convert and form price data
if ($this->currency_code != $this->def_currency) {
$product['product_price'] = $this->convertPrice($product['product_price'], $this->def_currency, $product['id_currency']);
$product['wholesale_price'] = $this->convertPrice($product['wholesale_price'], $this->def_currency, $product['id_currency']);
}
$product['product_price'] = $this->displayPrice($product['product_price'], $product['id_currency']);
$product['wholesale_price'] = $this->displayPrice($product['wholesale_price'], $product['id_currency']);
// Get url of product image
$image_url = $this->getProductImageUrl($product['id_product'], $product['link_rewrite']);
if ($image_url) {
$product['product_image'] = $image_url;
}
$cart_products[] = $product;
}
// Get cart product count
$cart_product_count_obj = new DbQuery();
$cart_product_count_obj->select('
COUNT(cp.id_product) AS product_count
');
$cart_product_count_obj->from('cart_product', 'cp');
$cart_product_count_obj->where('cp.id_cart = ' . (int) $this->cart_id);
//.........这里部分代码省略.........
示例5: getAvailableCarrierList
/**
* For a given {product, warehouse}, gets the carrier available
*
* @param JeproshopProductModelProduct $product The id of the product, or an array with at least the package size and weight
* @param int $warehouse_id
* @param int $address_delivery_id
* @param int $shop_id
* @param $cart
* @return array
*/
public static function getAvailableCarrierList(JeproshopProductModelProduct $product, $warehouse_id, $address_delivery_id = null, $shop_id = null, $cart = null)
{
if (is_null($shop_id)) {
$shop_id = JeproshopContext::getContext()->shop->shop_id;
}
if (is_null($cart)) {
$cart = JeproshopContext::getContext()->cart;
}
$address_id = (int) (!is_null($address_delivery_id) && $address_delivery_id != 0 ? $address_delivery_id : $cart->address_delivery_id);
if ($address_id) {
$address = new JeproshopAddressModelAddress($address_id);
$zone_id = JeproshopAddressModelAddress::getZoneIdByAddressId($address->address_id);
// Check the country of the address is activated
if (!JeproshopAddressModelAddress::isCountryActiveById($address->address_id)) {
return array();
}
} else {
$country = new JeproshopCountryModelCountry(JeproshopSettingModelSetting::getValue('default_country'));
$izone_id = $country->zone_id;
}
// Does the product is linked with carriers?
$query = new DbQuery();
$query->select('id_carrier');
$query->from('product_carrier', 'pc');
$query->innerJoin('carrier', 'c', 'c.id_reference = pc.id_carrier_reference AND c.deleted = 0');
$query->where('pc.id_product = ' . (int) $product->product_id);
$query->where('pc.id_shop = ' . (int) $shop_id);
$cache_id = 'Carrier::getAvailableCarrierList_' . (int) $product->id . '-' . (int) $id_shop;
if (!Cache::isStored($cache_id)) {
$carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
Cache::store($cache_id, $carriers_for_product);
}
$carriers_for_product = Cache::retrieve($cache_id);
$carrier_list = array();
if (!empty($carriers_for_product)) {
//the product is linked with carriers
foreach ($carriers_for_product as $carrier) {
//check if the linked carriers are available in current zone
if (Carrier::checkCarrierZone($carrier['id_carrier'], $id_zone)) {
$carrier_list[] = $carrier['id_carrier'];
}
}
if (empty($carrier_list)) {
return array();
}
//no linked carrier are available for this zone
}
// The product is not directly linked with a carrier
// Get all the carriers linked to a warehouse
if ($warehouse_id) {
$warehouse = new JeproshopWarehouseModelWarehouse($warehouse_id);
$warehouse_carrier_list = $warehouse->getCarriers();
}
$available_carrier_list = array();
$customer = new JeproshopCustomerModelCustomer($cart->customer_id);
$carriers = JeproshopCarrierModelCarrier::getCarriersForOrder($zone_id, $customer->getGroups(), $cart);
foreach ($carriers as $carrier) {
$available_carrier_list[] = $carrier->carrier_id;
}
if ($carrier_list) {
$carrier_list = array_intersect($available_carrier_list, $carrier_list);
} else {
$carrier_list = $available_carrier_list;
}
if (isset($warehouse_carrier_list)) {
$carrier_list = array_intersect($carrier_list, $warehouse_carrier_list);
}
if ($product->width > 0 || $product->height > 0 || $product->depth > 0 || $product->weight > 0) {
foreach ($carrier_list as $key => $carrier_id) {
$carrier = new JeproshopCarrierModelCarrier($carrier_id);
if ($carrier->max_width > 0 && $carrier->max_width < $product->width || $carrier->max_height > 0 && $carrier->max_height < $product->height || $carrier->max_depth > 0 && $carrier->max_depth < $product->depth || $carrier->max_weight > 0 && $carrier->max_weight < $product->weight) {
unset($carrier_list[$key]);
}
}
}
return $carrier_list;
}
示例6: getAvailableCarrierList
/**
* For a given {product, warehouse}, gets the carrier available
*
* @since 1.5.0
*
* @param Product $product The id of the product, or an array with at least the package size and weight
* @param int $id_warehouse Warehouse ID
* @param int $id_address_delivery Delivery Address ID
* @param int $id_shop Shop ID
* @param Cart $cart Cart object
* @param array &$error contain an error message if an error occurs
*
* @return array Available Carriers
* @throws PrestaShopDatabaseException
*/
public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null, $cart = null, &$error = array())
{
static $ps_country_default = null;
if ($ps_country_default === null) {
$ps_country_default = Configuration::get('PS_COUNTRY_DEFAULT');
}
if (is_null($id_shop)) {
$id_shop = Context::getContext()->shop->id;
}
if (is_null($cart)) {
$cart = Context::getContext()->cart;
}
if (is_null($error) || !is_array($error)) {
$error = array();
}
$id_address = (int) (!is_null($id_address_delivery) && $id_address_delivery != 0 ? $id_address_delivery : $cart->id_address_delivery);
if ($id_address) {
$id_zone = Address::getZoneById($id_address);
// Check the country of the address is activated
if (!Address::isCountryActiveById($id_address)) {
return array();
}
} else {
$country = new Country($ps_country_default);
$id_zone = $country->id_zone;
}
// Does the product is linked with carriers?
$cache_id = 'Carrier::getAvailableCarrierList_' . (int) $product->id . '-' . (int) $id_shop;
if (!Cache::isStored($cache_id)) {
$query = new DbQuery();
$query->select('id_carrier');
$query->from('product_carrier', 'pc');
$query->innerJoin('carrier', 'c', 'c.id_reference = pc.id_carrier_reference AND c.deleted = 0 AND c.active = 1');
$query->where('pc.id_product = ' . (int) $product->id);
$query->where('pc.id_shop = ' . (int) $id_shop);
$carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
Cache::store($cache_id, $carriers_for_product);
} else {
$carriers_for_product = Cache::retrieve($cache_id);
}
$carrier_list = array();
if (!empty($carriers_for_product)) {
//the product is linked with carriers
foreach ($carriers_for_product as $carrier) {
//check if the linked carriers are available in current zone
if (Carrier::checkCarrierZone($carrier['id_carrier'], $id_zone)) {
$carrier_list[$carrier['id_carrier']] = $carrier['id_carrier'];
}
}
if (empty($carrier_list)) {
return array();
}
//no linked carrier are available for this zone
}
// The product is not directly linked with a carrier
// Get all the carriers linked to a warehouse
if ($id_warehouse) {
$warehouse = new Warehouse($id_warehouse);
$warehouse_carrier_list = $warehouse->getCarriers();
}
$available_carrier_list = array();
$cache_id = 'Carrier::getAvailableCarrierList_getCarriersForOrder_' . (int) $id_zone . '-' . (int) $cart->id;
if (!Cache::isStored($cache_id)) {
$customer = new Customer($cart->id_customer);
$carrier_error = array();
$carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups(), $cart, $carrier_error);
Cache::store($cache_id, array($carriers, $carrier_error));
} else {
list($carriers, $carrier_error) = Cache::retrieve($cache_id);
}
$error = array_merge($error, $carrier_error);
foreach ($carriers as $carrier) {
$available_carrier_list[$carrier['id_carrier']] = $carrier['id_carrier'];
}
if ($carrier_list) {
$carrier_list = array_intersect($available_carrier_list, $carrier_list);
} else {
$carrier_list = $available_carrier_list;
}
if (isset($warehouse_carrier_list)) {
$carrier_list = array_intersect($carrier_list, $warehouse_carrier_list);
}
$cart_quantity = 0;
$cart_weight = 0;
foreach ($cart->getProducts(false, false) as $cart_product) {
//.........这里部分代码省略.........
示例7: getWarehouses
/**
* Gets available warehouses
* It is possible via ignore_shop and id_shop to filter the list with shop id
*
* @param bool $ignore_shop Optional, false by default - Allows to get only the warehouses that are associated to one/some shops (@see $id_shop)
* @param int $id_shop Optional, Context::shop::Id by default - Allows to define a specific shop to filter.
* @return array Warehouses (ID, reference/name concatenated)
*/
public static function getWarehouses($ignore_shop = false, $id_shop = null)
{
if (!$ignore_shop) {
if (is_null($id_shop)) {
$id_shop = Context::getContext()->shop->id;
}
}
$query = new DbQuery();
$query->select('w.id_warehouse, CONCAT(reference, \' - \', name) as name');
$query->from('warehouse', 'w');
$query->where('deleted = 0');
$query->orderBy('reference ASC');
if (!$ignore_shop) {
$query->innerJoin('warehouse_shop', 'ws', 'ws.id_warehouse = w.id_warehouse AND ws.id_shop = ' . (int) $id_shop);
}
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
}
示例8: getAvailableCarrierList
/**
* For a given {product, warehouse}, gets the carrier available
*
* @since 1.5.0
* @param Product $product The id of the product, or an array with at least the package size and weight
* @return array
*/
public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null, $cart = null)
{
if (is_null($id_shop)) {
$id_shop = Context::getContext()->shop->id;
}
if (is_null($cart)) {
$cart = Context::getContext()->cart;
}
$id_address = (int) (!is_null($id_address_delivery) && $id_address_delivery != 0 ? $id_address_delivery : $cart->id_address_delivery);
if ($id_address) {
$address = new Address($id_address);
$id_zone = Address::getZoneById($address->id);
// Check the country of the address is activated
if (!Address::isCountryActiveById($address->id)) {
return array();
}
} else {
$country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'));
$id_zone = $country->id_zone;
}
// Does the product is linked with carriers?
$query = new DbQuery();
$query->select('id_carrier');
$query->from('product_carrier', 'pc');
$query->innerJoin('carrier', 'c', 'c.id_reference = pc.id_carrier_reference AND c.deleted = 0');
$query->where('pc.id_product = ' . (int) $product->id);
$query->where('pc.id_shop = ' . (int) $id_shop);
$carriers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
if (!empty($carriers)) {
//the product is linked with carriers
$carrier_list = array();
foreach ($carriers as $carrier) {
//check if the linked carriers are available in current zone
if (Carrier::checkCarrierZone($carrier['id_carrier'], $id_zone)) {
$carrier_list[] = $carrier['id_carrier'];
}
}
if (!empty($carrier_list)) {
return $carrier_list;
} else {
return array();
}
//no linked carrier are available for this zone
}
$carrier_list = array();
// The product is not dirrectly linked with a carrier
// Get all the carriers linked to a warehouse
if ($id_warehouse) {
$warehouse = new Warehouse($id_warehouse);
$warehouse_carrier_list = $warehouse->getCarriers();
}
$available_carrier_list = array();
$customer = new Customer($cart->id_customer);
$carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups(), $cart);
foreach ($carriers as $carrier) {
$available_carrier_list[] = $carrier['id_carrier'];
}
if (empty($warehouse_carrier_list)) {
$carrier_list = $available_carrier_list;
} else {
$carrier_list = array_intersect($warehouse_carrier_list, $available_carrier_list);
}
if ($product->width > 0 || $product->height > 0 || $product->depth > 0 || $product->weight > 0) {
foreach ($carrier_list as $key => $id_carrier) {
$carrier = new Carrier($id_carrier);
if ($carrier->max_width > 0 && $carrier->max_width < $product->width || $carrier->max_height > 0 && $carrier->max_height < $product->height || $carrier->max_depth > 0 && $carrier->max_depth < $product->depth || $carrier->max_weight > 0 && $carrier->max_weight < $product->weight) {
unset($carrier_list[$key]);
}
}
}
return $carrier_list;
}
示例9: ajaxGetProductsForSupplyOrder
public function ajaxGetProductsForSupplyOrder()
{
require_once _PS_MODULE_DIR_ . 'erpillicopresta/classes/stock/ErpSupplyOrderClasses.php';
require_once _PS_MODULE_DIR_ . 'erpillicopresta/erpillicopresta.php';
/* manage advanced stock */
$stock_management_active = Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT');
$sales_forecast_type = Configuration::get('ERP_SALES_FORECAST_CHOICE');
$id_supplier = (int) Tools::getValue('id_supplier', false);
$id_currency = (int) Tools::getValue('id_currency', false);
$id_categorie = (int) Tools::getValue('id_categorie', false);
$id_manufacturer = (int) Tools::getValue('id_manufacturer', false);
$id_warehouse = (int) Tools::getValue('id_warehouse', null);
$existing_ids = Tools::getValue('ids');
//$token_get_product = Tools::getValue('token');
$products = ErpSupplyOrderClasses::searchProduct($id_supplier, $id_categorie, $id_manufacturer, $id_currency);
if (!empty($products)) {
$advanced_stock_token = Tools::getAdminToken('AdminAdvancedStock' . (int) Tab::getIdFromClassName('AdminAdvancedStock') . (int) $this->context->employee->id);
foreach ($products as $product) {
// If product already in destination array, continue
if (strrpos($existing_ids, $product['id']) !== false) {
continue;
}
$ids = explode('_', $product['id']);
$id_product = $ids[0];
$id_product_attribute = $ids[1];
// If the advanced stock manager is activated
if ($stock_management_active == '1') {
// Get the physical and usable quantities
$query = new DbQuery();
$query->select('physical_quantity');
$query->select('usable_quantity');
$query->from('stock');
$query->where('id_product = ' . (int) $id_product . ' AND id_product_attribute = ' . (int) $id_product_attribute);
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
/* the two quantities */
$physical_quantity = (int) $res['physical_quantity'];
$usable_quantity = (int) $res['usable_quantity'];
// The real quantity depends of the warehouse
$manager = StockManagerFactory::getManager();
$product['stock'] = $real_quantity = (int) $manager->getProductRealQuantities($id_product, $id_product_attribute, $id_warehouse, true);
} else {
// get the free quantities
$product['stock'] = $usable_quantity = (int) Product::getQuantity($id_product, $id_product_attribute);
}
/* TAX */
/* Get the current tax */
$query = new DbQuery();
$query->select('rate');
$query->from('tax', 't');
$query->innerJoin('tax_rule', 'tr', 'tr.id_tax = t.id_tax');
$query->innerJoin('product', 'p', 'p.id_tax_rules_group = tr.id_tax_rules_group');
$query->where('p.id_product = ' . (int) $id_product);
$query->where('tr.id_country IN (SELECT id_country
FROM ' . _DB_PREFIX_ . 'address
WHERE id_supplier = ' . (int) $id_supplier . ')');
$product['tax_rate'] = round(Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query), 1);
$prices = ErpSupplyOrderClasses::getWholesalePrice((int) $id_product, (int) $id_product_attribute, (int) $id_supplier);
$product['unit_price_te'] = Tools::convertPriceFull($prices, new Currency((int) $id_currency));
// sales quantity for X rolling month
$quantity_sales = ErpSupplyOrderClasses::getQuantitySales((int) $id_product, (int) $id_product_attribute);
// if sale forecast is activ
if ($sales_forecast_type != 0) {
// if we use the 6 month rolling method
if ($sales_forecast_type == 1) {
$sales_forecasts = round(ErpSupplyOrderClasses::getProductSalesForecasts($id_product, $id_product_attribute), 1);
} else {
$sales_forecasts = round(ErpSupplyOrderClasses::getProductSalesForecastsByPeriod($id_product, $id_product_attribute), 1);
}
} else {
$sales_forecasts = 'NA';
}
// Sales gain
$sales_gains = ErpSupplyOrderClasses::getProductSalesGains($id_product, $id_product_attribute);
// Prepare the hidden json foreach line
$product['comment'] = '';
$product_json = Tools::jsonEncode($product);
echo '<tr>
<td class="product_json hide">' . $product_json . '</td>
<td><input type="checkbox" class="select_product" name="select_product"/></td>
<td>' . $product['supplier_reference'] . '</td>
<td>' . $product['reference'] . '</td>
<td>
<a href="#" class="cluetip-supply-price" title="' . $this->l('Supplier Price') . '"
rel="index.php?controller=AdminAdvancedStock&ajax=1&id_product=' . $id_product . '&id_product_attribute=' . $id_product_attribute . '&id_currency=' . $id_currency . '&task=getProductSupplierPrice&token=' . $advanced_stock_token . '" >
<img src="themes/default/img/icon-search.png">
</a>
' . $product['name'] . '
</td>';
if (Configuration::get(ErpIllicopresta::getControllerStatusName('AdminAdvancedSupplyOrder'))) {
echo '<td align="center"> <p style="background-color:' . ErpSupplyOrderClasses::getStockLevelColor($real_quantity) . '; width:16px; height:16px"></p> </td>';
}
echo '<td align="center">' . $usable_quantity . '</td>
' . ($stock_management_active == '1' ? '
<td align="center">' . $physical_quantity . '</td>
<td align="center">' . $real_quantity . '</td>' : '') . '';
if (Configuration::get(ErpIllicopresta::getControllerStatusName('AdminAdvancedSupplyOrder'))) {
echo '<td align="center">' . $quantity_sales . '</td>
<td align="center">' . $sales_gains . '</td>';
if (Configuration::get('ERP_SALES_FORECAST_CHOICE') != 0) {
echo '<td>' . $sales_forecasts . '</td>';
//.........这里部分代码省略.........
示例10: getWholesalePrice
public static function getWholesalePrice($id_product, $id_product_attribute = 0, $id_supplier = 0)
{
// If there's a supplier
if (!empty($id_supplier)) {
// Getting supplier's price first
$prices = ErpProductSupplier::getProductSupplierPrice($id_product, $id_product_attribute, $id_supplier, true);
$price = $prices['product_supplier_price_te'];
}
// If no supplier's price, or supplier's price null, we look for the price of the product or variation
if (empty($price) || $price == '0.000000') {
// No variation, looking for product's price
if ($id_product_attribute == 0) {
$query = new DbQuery();
$query->select('wholesale_price');
$query->from('product');
$query->where('id_product = ' . (int) $id_product);
$price = Db::getInstance()->getValue($query);
} else {
$query = new DbQuery();
$query->select('p.wholesale_price as wholesale_price_product, pa.wholesale_price as wholesale_price_product_attribute');
$query->from('product_attribute', 'pa');
$query->where('pa.id_product = ' . (int) $id_product);
$query->where('pa.id_product_attribute = ' . (int) $id_product_attribute);
$query->innerJoin('product', 'p', ' p.id_product = pa.id_product');
$prices = Db::getInstance()->getRow($query);
// if variation's price
if (!empty($prices['wholesale_price_product_attribute']) && $prices['wholesale_price_product_attribute'] != '0.000000') {
$price = $prices['wholesale_price_product_attribute'];
} elseif (!empty($prices['wholesale_price_product']) && $prices['wholesale_price_product'] != '0.000000') {
$price = $prices['wholesale_price_product'];
} else {
$price = '0.00000';
}
}
}
return $price;
}
示例11: getWholesalePrice
public static function getWholesalePrice($id_product, $id_product_attribute = 0, $id_supplier = 0)
{
// If there is a supplier
if (!empty($id_supplier)) {
//On récupère tout d'abord le prix du fournisseur
$prices = ErpProductSupplier::getProductSupplierPrice($id_product, $id_product_attribute, $id_supplier, true);
if (isset($prices['product_supplier_price_te'])) {
$price = $prices['product_supplier_price_te'];
}
}
// If no price for this supplier, or supplier price null,
// get the price of the product or variation
if (empty($price) || $price == '0.000000') {
// pas de décliaison, on cherche le prix du produit
if ($id_product_attribute == 0) {
$query = new DbQuery();
$query->select('wholesale_price');
$query->from('product');
$query->where('id_product = ' . (int) $id_product);
$price = Db::getInstance()->getValue($query);
} else {
$query = new DbQuery();
$query->select('p.wholesale_price as wholesale_price_product, pa.wholesale_price as wholesale_price_product_attribute');
$query->from('product_attribute', 'pa');
$query->where('pa.id_product = ' . (int) $id_product);
$query->where('pa.id_product_attribute = ' . (int) $id_product_attribute);
$query->innerJoin('product', 'p', ' p.id_product = pa.id_product');
$prices = Db::getInstance()->getRow($query);
//If variation has a price
if ($prices['wholesale_price_product_attribute'] == '0.000000') {
$price = $prices['wholesale_price_product'];
} elseif ($prices['wholesale_price_product_attribute'] != '0.000000') {
$price = $prices['wholesale_price_product_attribute'];
} else {
$price = '0.00000';
}
}
}
return $price;
}
示例12: getblogPages
public static function getblogPages($id_lang = null, $id_leoblogcat = null, $active = true, $id_shop = null)
{
$sql = new DbQuery();
$sql->select('*');
$sql->from('blog', 'c');
if ($id_lang) {
$sql->innerJoin('blog_lang', 'l', 'c.id_leoblog_blog = l.id_leoblog_blog AND l.id_lang = ' . (int) $id_lang);
}
if ($id_shop) {
$sql->innerJoin('blog_shop', 'cs', 'c.id_leoblog_blog = cs.id_leoblog_blog AND cs.id_shop = ' . (int) $id_shop);
}
if ($active) {
$sql->where('c.active = 1');
}
if ($id_leoblogcat) {
$sql->where('c.id_leoblogcat = ' . (int) $id_leoblogcat);
}
$sql->orderBy('position');
return Db::getInstance()->executeS($sql);
}
示例13: getCustomersSmsRequest
public static function getCustomersSmsRequest($campaign_id, $checked_langs, $checked_groups, $checked_campaign_active, $checked_products, $checked_categories, $limit = 0, &$list_total = null)
{
$sql_calc_found = is_null($list_total) ? '' : 'SQL_CALC_FOUND_ROWS ';
$req = new DbQuery();
$req->select($sql_calc_found . (int) $campaign_id . ' as campaign_id, address.phone_mobile as target,
address.phone_mobile as col_0, customer.lastname as col_1, customer.firstname as col_2,address.postcode as col_3,
address.city as col_4, \'prestashop\' as source');
$req->from('customer', 'customer');
$req->leftJoin('customer_group', 'customer_group', 'customer_group.id_customer = customer.id_customer');
$req->leftJoin('guest', 'guest', 'guest.id_customer = customer.id_customer');
$req->leftJoin('connections', 'connections', 'connections.id_guest = guest.id_guest');
$req->innerJoin('address', 'address', 'address.id_customer = customer.id_customer AND address.phone_mobile <> \'\'');
$req->leftJoin('country', 'country', 'address.id_country = country.id_country');
$where = array();
$where[] = 'address.phone_mobile IS NOT NULL AND address.phone_mobile <> \'\'';
if (!empty($checked_langs)) {
$where[] = 'customer.id_lang IN(' . implode(', ', array_map('intval', $checked_langs)) . ')';
}
if (!empty($checked_groups)) {
$where[] = 'customer_group.id_group IN(' . implode(', ', array_map('intval', $checked_groups)) . ')';
}
if ($checked_campaign_active) {
$where[] = 'customer.active = 1';
}
if (!empty($checked_products) || !empty($checked_categories)) {
$where_products_categories = array();
$req->leftJoin('cart', 'cart', 'cart.id_customer = customer.id_customer');
$req->leftJoin('cart_product', 'cart_product', 'cart_product.id_cart = cart.id_cart');
if (!empty($checked_products)) {
$where_products_categories[] = 'cart_product.id_product IN(' . implode(', ', array_map('intval', $checked_products)) . ')';
}
if (!empty($checked_categories)) {
$req->leftJoin('category_product', 'category_product', 'category_product.id_product = cart_product.id_product');
$where_products_categories[] = 'category_product.id_category IN(' . implode(', ', array_map('intval', $checked_categories)) . ')';
}
$where[] = implode(' OR ', $where_products_categories);
}
$req->where(implode(' AND ', $where));
$req->orderby('customer.id_customer');
$req->groupby('customer.id_customer');
$limit = (int) $limit;
if ($limit) {
$req->limit($limit);
}
return $req;
}
示例14: getHookModuleExecList
/**
* Get list of modules we can execute per hook
*
* @since 1.5.0
* @param string $hook_name Get list of modules for this hook if given
* @return array
*/
public static function getHookModuleExecList($hook_name = null)
{
$context = Context::getContext();
$cache_id = 'hook_module_exec_list_' . (isset($context->shop->id) ? '_' . $context->shop->id : '') . (isset($context->customer) ? '_' . $context->customer->id : '');
if (!Cache::isStored($cache_id) || $hook_name == 'displayPayment' || $hook_name == 'displayPaymentEU' || $hook_name == 'displayBackOfficeHeader') {
$frontend = true;
$groups = array();
$use_groups = Group::isFeatureActive();
if (isset($context->employee)) {
$frontend = false;
} else {
// Get groups list
if ($use_groups) {
if (isset($context->customer) && $context->customer->isLogged()) {
$groups = $context->customer->getGroups();
} elseif (isset($context->customer) && $context->customer->isLogged(true)) {
$groups = array((int) Configuration::get('PS_GUEST_GROUP'));
} else {
$groups = array((int) Configuration::get('PS_UNIDENTIFIED_GROUP'));
}
}
}
// SQL Request
$sql = new DbQuery();
$sql->select('h.`name` as hook, m.`id_module`, h.`id_hook`, m.`name` as module, h.`live_edit`');
$sql->from('module', 'm');
if ($hook_name != 'displayBackOfficeHeader') {
$sql->join(Shop::addSqlAssociation('module', 'm', true, 'module_shop.enable_device & ' . (int) Context::getContext()->getDevice()));
$sql->innerJoin('module_shop', 'ms', 'ms.`id_module` = m.`id_module`');
}
$sql->innerJoin('hook_module', 'hm', 'hm.`id_module` = m.`id_module`');
$sql->innerJoin('hook', 'h', 'hm.`id_hook` = h.`id_hook`');
if ($hook_name != 'displayPayment' && $hook_name != 'displayPaymentEU') {
$sql->where('h.`name` != "displayPayment" AND h.`name` != "displayPaymentEU"');
} elseif ($frontend) {
if (Validate::isLoadedObject($context->country)) {
$sql->where('((h.`name` = "displayPayment" OR h.`name` = "displayPaymentEU") AND (SELECT `id_country` FROM `' . _DB_PREFIX_ . 'module_country` mc WHERE mc.`id_module` = m.`id_module` AND `id_country` = ' . (int) $context->country->id . ' AND `id_shop` = ' . (int) $context->shop->id . ' LIMIT 1) = ' . (int) $context->country->id . ')');
}
if (Validate::isLoadedObject($context->currency)) {
$sql->where('((h.`name` = "displayPayment" OR h.`name` = "displayPaymentEU") AND (SELECT `id_currency` FROM `' . _DB_PREFIX_ . 'module_currency` mcr WHERE mcr.`id_module` = m.`id_module` AND `id_currency` IN (' . (int) $context->currency->id . ', -1, -2) LIMIT 1) IN (' . (int) $context->currency->id . ', -1, -2))');
}
}
if (Validate::isLoadedObject($context->shop)) {
$sql->where('hm.`id_shop` = ' . (int) $context->shop->id);
}
if ($frontend) {
if ($use_groups) {
$sql->leftJoin('module_group', 'mg', 'mg.`id_module` = m.`id_module`');
if (Validate::isLoadedObject($context->shop)) {
$sql->where('mg.`id_shop` = ' . (int) $context->shop->id . (count($groups) ? ' AND mg.`id_group` IN (' . implode(', ', $groups) . ')' : ''));
} elseif (count($groups)) {
$sql->where('mg.`id_group` IN (' . implode(', ', $groups) . ')');
}
}
}
$sql->groupBy('hm.id_hook, hm.id_module');
$sql->orderBy('hm.`position`');
$list = array();
if ($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql)) {
foreach ($result as $row) {
$row['hook'] = strtolower($row['hook']);
if (!isset($list[$row['hook']])) {
$list[$row['hook']] = array();
}
$list[$row['hook']][] = array('id_hook' => $row['id_hook'], 'module' => $row['module'], 'id_module' => $row['id_module'], 'live_edit' => $row['live_edit']);
}
}
if ($hook_name != 'displayPayment' && $hook_name != 'displayPaymentEU' && $hook_name != 'displayBackOfficeHeader') {
Cache::store($cache_id, $list);
// @todo remove this in 1.6, we keep it in 1.5 for backward compatibility
self::$_hook_modules_cache_exec = $list;
}
} else {
$list = Cache::retrieve($cache_id);
}
// If hook_name is given, just get list of modules for this hook
if ($hook_name) {
$retro_hook_name = strtolower(Hook::getRetroHookName($hook_name));
$hook_name = strtolower($hook_name);
$return = array();
$inserted_modules = array();
if (isset($list[$hook_name])) {
$return = $list[$hook_name];
}
foreach ($return as $module) {
$inserted_modules[] = $module['id_module'];
}
if (isset($list[$retro_hook_name])) {
foreach ($list[$retro_hook_name] as $retro_module_call) {
if (!in_array($retro_module_call['id_module'], $inserted_modules)) {
$return[] = $retro_module_call;
}
}
//.........这里部分代码省略.........
示例15: DbQuery
$id_supplier = Tools::getValue('id_supplier');
$id_currency = Tools::isSubmit('id_currency') ? Tools::getValue('id_currency') : Context::getContext()->id_currency;
/* get lang from context */
$id_lang = (int) Context::getContext()->language->id;
$query = new DbQuery();
$query->select('
CONCAT(p.id_product, \'_\', IFNULL(pa.id_product_attribute, \'0\')) as id,
ps.product_supplier_reference as supplier_reference,
IFNULL(pa.reference, IFNULL(p.reference, \'\')) as reference,
IFNULL(pa.ean13, IFNULL(p.ean13, \'\')) as ean13,
IFNULL(pa.upc, IFNULL(p.upc, \'\')) as upc,
md5(CONCAT(\'' . _COOKIE_KEY_ . '\', p.id_product, \'_\', IFNULL(pa.id_product_attribute, \'0\'))) as checksum,
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(DISTINCT agl.name, \' - \', al.name SEPARATOR \', \')), pl.name) as name
');
$query->from('product', 'p');
$query->innerJoin('product_lang', 'pl', 'pl.id_product = p.id_product AND pl.id_lang = ' . (int) $id_lang);
$query->leftJoin('product_attribute', 'pa', 'pa.id_product = p.id_product');
$query->leftJoin('product_attribute_combination', 'pac', 'pac.id_product_attribute = pa.id_product_attribute');
$query->leftJoin('attribute', 'atr', 'atr.id_attribute = pac.id_attribute');
$query->leftJoin('attribute_lang', 'al', 'al.id_attribute = atr.id_attribute AND al.id_lang = ' . (int) $id_lang);
$query->leftJoin('attribute_group_lang', 'agl', 'agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = ' . (int) $id_lang);
$query->leftJoin('product_supplier', 'ps', 'ps.id_product = p.id_product AND ps.id_product_attribute = IFNULL(pa.id_product_attribute, 0)');
$query->where('p.id_product NOT IN (SELECT pd.id_product FROM `' . _DB_PREFIX_ . 'product_download` pd WHERE (pd.id_product = p.id_product))');
$query->where('p.is_virtual = 0 AND p.cache_is_pack = 0');
$query->where('p.id_product = ' . (int) $id_product . '');
$query->groupBy('p.id_product, pa.id_product_attribute');
$item = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
$ids = explode('_', $item['id']);
if ($item) {
die(Tools::jsonEncode($item));
}