本文整理汇总了PHP中Product::getProductProperties方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::getProductProperties方法的具体用法?PHP Product::getProductProperties怎么用?PHP Product::getProductProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product::getProductProperties方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderContent
public function renderContent($setting)
{
$t = array('product_id' => 0, 'image_height' => '320', 'image_width' => 300);
$setting = array_merge($t, $setting);
$id_lang = (int) $this->lang_id;
$id_product = $setting['product_id'];
$sql = 'SELECT p.*, product_shop.*, stock.`out_of_stock` out_of_stock, pl.`description`, pl.`description_short`,
pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
p.`ean13`, p.`upc`, MAX(image_shop.`id_image`) id_image, il.`legend`,
DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(),
INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . '
DAY)) > 0 AS new
FROM `' . _DB_PREFIX_ . 'product` p
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . '
)
' . Shop::addSqlAssociation('product', 'p') . '
LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . '
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
' . Product::sqlStock('p', 0) . '
WHERE p.id_product = ' . (int) $id_product . '
GROUP BY product_shop.id_product';
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (!$row) {
return false;
}
if (isset($row['id_product_attribute']) && $row['id_product_attribute']) {
$row['id_product_attribute'] = $row['id_product_attribute'];
}
$p = Product::getProductProperties($id_lang, $row);
$setting['product'] = $p;
$output = array('type' => 'product', 'data' => $setting);
return $output;
}
示例2: getPacksTable
public static function getPacksTable($id_product, $id_lang, $full = false, $limit = NULL)
{
$price_sql = Product::getProductPriceSql('p.id_product', 'pp');
$sql = "\n\t\t SELECT\n p.*, pl.*, i.`id_image`, il.`legend`, t.`rate`\n\t\t FROM\n `PREFIX_product` p\n\t\t NATURAL LEFT JOIN `PREFIX_product_lang` pl\n\t\t LEFT JOIN `PREFIX_image` i ON\n i.`id_product` = p.`id_product` AND i.`cover` = 1\n\t\t LEFT JOIN `PREFIX_image_lang` il ON\n i.`id_image` = il.`id_image` AND il.`id_lang` = {$id_lang}\n {$price_sql}\n\t\t LEFT JOIN `PREFIX_tax` t ON\n t.`id_tax` = pp.`id_tax`\n\t\t WHERE pl.`id_lang` = {$id_lang}\n\t\t AND p.`id_product` IN (\n\t\t\t SELECT a.`id_product_pack`\n\t\t\t FROM `PREFIX_pack` a\n\t\t\t WHERE a.`id_product_item` = {$id_product})\n\t\t";
$sql = str_replace('PREFIX_', _DB_PREFIX_, $sql);
$result = Db::getInstance()->ExecuteS($sql);
if ($limit) {
$sql .= ' LIMIT ' . intval($limit);
}
$result = Db::getInstance()->ExecuteS($sql);
if (!$full) {
return $result;
}
$arrayResult = array();
foreach ($result as $row) {
if (!Pack::isPacked($row['id_product'])) {
$arrayResult[] = Product::getProductProperties($id_lang, $row);
}
}
return $arrayResult;
}
示例3: getPacksTable
public static function getPacksTable($id_product, $id_lang, $full = false, $limit = null)
{
if (!Pack::isFeatureActive()) {
return array();
}
$packs = Db::getInstance()->getValue('
SELECT GROUP_CONCAT(a.`id_product_pack`)
FROM `' . _DB_PREFIX_ . 'pack` a
WHERE a.`id_product_item` = ' . (int) $id_product);
if (!(int) $packs) {
return array();
}
$context = Context::getContext();
$sql = '
SELECT p.*, product_shop.*, pl.*, image_shop.`id_image` id_image, il.`legend`, IFNULL(product_attribute_shop.id_product_attribute, 0) id_product_attribute
FROM `' . _DB_PREFIX_ . 'product` p
NATURAL LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
' . Shop::addSqlAssociation('product', 'p') . '
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_shop` product_attribute_shop
ON (p.`id_product` = product_attribute_shop.`id_product` AND product_attribute_shop.`default_on` = 1 AND product_attribute_shop.id_shop=' . (int) $context->shop->id . ')
LEFT JOIN `' . _DB_PREFIX_ . 'image_shop` image_shop
ON (image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop=' . (int) $context->shop->id . ')
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
WHERE pl.`id_lang` = ' . (int) $id_lang . '
' . Shop::addSqlRestrictionOnLang('pl') . '
AND p.`id_product` IN (' . $packs . ')
GROUP BY p.id_product';
if ($limit) {
$sql .= ' LIMIT ' . (int) $limit;
}
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (!$full) {
return $result;
}
$array_result = array();
foreach ($result as $row) {
if (!Pack::isPacked($row['id_product'])) {
$array_result[] = Product::getProductProperties($id_lang, $row);
}
}
return $array_result;
}
示例4: getPacksTable
public static function getPacksTable($id_product, $id_lang, $full = false, $limit = null)
{
if (!Pack::isFeatureActive()) {
return array();
}
$packs = Db::getInstance()->getValue('
SELECT GROUP_CONCAT(a.`id_product_pack`)
FROM `' . _DB_PREFIX_ . 'pack` a
WHERE a.`id_product_item` = ' . (int) $id_product);
if (!(int) $packs) {
return array();
}
$sql = '
SELECT p.*, product_shop.*, pl.*, image_shop.`id_image`, il.`legend`
FROM `' . _DB_PREFIX_ . 'product` p
NATURAL LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
' . Shop::addSqlAssociation('product', 'p') . '
LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . '
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
WHERE pl.`id_lang` = ' . (int) $id_lang . '
' . Shop::addSqlRestrictionOnLang('pl') . '
AND p.`id_product` IN (' . $packs . ')
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))';
if ($limit) {
$sql .= ' LIMIT ' . (int) $limit;
}
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (!$full) {
return $result;
}
$array_result = array();
foreach ($result as $row) {
if (!Pack::isPacked($row['id_product'])) {
$array_result[] = Product::getProductProperties($id_lang, $row);
}
}
return $array_result;
}
示例5: hookActionCartSave
/**
* hook save cart event to implement addtocart and remove from cart functionality
*/
public function hookActionCartSave()
{
if (!isset($this->context->cart)) {
return;
}
if (!Tools::getIsset('id_product')) {
return;
}
$cart = array('controller' => Tools::getValue('controller'), 'addAction' => Tools::getValue('add') ? 'add' : '', 'removeAction' => Tools::getValue('delete') ? 'delete' : '', 'extraAction' => Tools::getValue('op'), 'qty' => (int) Tools::getValue('qty', 1));
$cart_products = $this->context->cart->getProducts();
if (isset($cart_products) && count($cart_products)) {
foreach ($cart_products as $cart_product) {
if ($cart_product['id_product'] == Tools::getValue('id_product')) {
$add_product = $cart_product;
}
}
}
if ($cart['removeAction'] == 'delete') {
$add_product_object = new Product((int) Tools::getValue('id_product'), true, (int) Configuration::get('PS_LANG_DEFAULT'));
if (Validate::isLoadedObject($add_product_object)) {
$add_product['name'] = $add_product_object->name;
$add_product['manufacturer_name'] = $add_product_object->manufacturer_name;
$add_product['category'] = $add_product_object->category;
$add_product['reference'] = $add_product_object->reference;
$add_product['link_rewrite'] = $add_product_object->link_rewrite;
$add_product['link'] = $add_product_object->link_rewrite;
$add_product['price'] = $add_product_object->price;
$add_product['ean13'] = $add_product_object->ean13;
$add_product['id_product'] = Tools::getValue('id_product');
$add_product['id_category_default'] = $add_product_object->id_category_default;
$add_product['out_of_stock'] = $add_product_object->out_of_stock;
$add_product = Product::getProductProperties((int) Configuration::get('PS_LANG_DEFAULT'), $add_product);
}
}
if (isset($add_product) && !in_array((int) Tools::getValue('id_product'), self::$products)) {
self::$products[] = (int) Tools::getValue('id_product');
$ga_products = $this->wrapProduct($add_product, $cart, 0, true);
if (array_key_exists('id_product_attribute', $ga_products) && $ga_products['id_product_attribute'] != '' && $ga_products['id_product_attribute'] != 0) {
$id_product = $ga_products['id_product_attribute'];
} else {
$id_product = Tools::getValue('id_product');
}
if (isset($this->context->cookie->ga_cart)) {
$gacart = unserialize($this->context->cookie->ga_cart);
} else {
$gacart = array();
}
if ($cart['removeAction'] == 'delete') {
$ga_products['quantity'] = -1;
} elseif ($cart['extraAction'] == 'down') {
if (array_key_exists($id_product, $gacart)) {
$ga_products['quantity'] = $gacart[$id_product]['quantity'] - $cart['qty'];
} else {
$ga_products['quantity'] = $cart['qty'] * -1;
}
} elseif (Tools::getValue('step') <= 0) {
if (array_key_exists($id_product, $gacart)) {
$ga_products['quantity'] = $gacart[$id_product]['quantity'] + $cart['qty'];
}
}
$gacart[$id_product] = $ga_products;
$this->context->cookie->ga_cart = serialize($gacart);
}
}
示例6: getPacksTable
public static function getPacksTable($id_product, $id_lang, $full = false, $limit = NULL)
{
$packs = Db::getInstance()->getValue('
SELECT GROUP_CONCAT(a.`id_product_pack`)
FROM `' . _DB_PREFIX_ . 'pack` a
WHERE a.`id_product_item` = ' . (int) $id_product);
if (!(int) $packs) {
return array();
}
$sql = '
SELECT p.*, pl.*, i.`id_image`, il.`legend`, t.`rate`
FROM `' . _DB_PREFIX_ . 'product` p
NATURAL LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
AND tr.`id_country` = ' . (int) Country::getDefaultCountryId() . '
AND tr.`id_state` = 0)
LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`)
LEFT JOIN `' . _DB_PREFIX_ . 'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = ' . (int) $id_lang . ')
WHERE pl.`id_lang` = ' . (int) $id_lang . '
AND p.`id_product` IN (' . $packs . ')';
if ($limit) {
$sql .= ' LIMIT ' . (int) $limit;
}
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
if (!$full) {
return $result;
}
$arrayResult = array();
foreach ($result as $row) {
if (!Pack::isPacked($row['id_product'])) {
$arrayResult[] = Product::getProductProperties($id_lang, $row);
}
}
return $arrayResult;
}
示例7: getProductsProperties
public static function getProductsProperties($id_lang, $query_result)
{
$resultsArray = array();
if (is_array($query_result)) {
foreach ($query_result as $row) {
if ($row2 = Product::getProductProperties($id_lang, $row)) {
$resultsArray[] = $row2;
}
}
}
return $resultsArray;
}
示例8: getPacksTable
public static function getPacksTable($id_product, $id_lang, $full = false, $limit = NULL)
{
$sql = '
SELECT p.*, pl.*, i.`id_image`, il.`legend`, t.`rate`
FROM `' . _DB_PREFIX_ . 'product` p
NATURAL LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . intval($id_lang) . ')
LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = p.`id_tax`)
WHERE pl.`id_lang` = ' . intval($id_lang) . '
AND p.`id_product` IN (
SELECT a.`id_product_pack`
FROM `' . _DB_PREFIX_ . 'pack` a
WHERE a.`id_product_item` = ' . intval($id_product) . ')
';
if ($limit) {
$sql .= ' LIMIT ' . intval($limit);
}
$result = Db::getInstance()->ExecuteS($sql);
if (!$full) {
return $result;
}
$arrayResult = array();
foreach ($result as $row) {
if (!Pack::isPacked($row['id_product'])) {
$arrayResult[] = Product::getProductProperties($id_lang, $row);
}
}
return $arrayResult;
}
示例9: _getProductById
protected function _getProductById($productId = 0, $id_lang, $active = true, Context $context = null)
{
if (!$productId) {
return array();
}
if (!$context) {
$context = Context::getContext();
}
$front = true;
if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) {
$front = false;
}
if (!Validate::isBool($active)) {
die(Tools::displayError());
}
$id_supplier = (int) Tools::getValue('id_supplier');
$sql = 'SELECT
p.id_product, MAX(product_attribute_shop.id_product_attribute) id_product_attribute, pl.`link_rewrite`, pl.`name`, pl.`description_short`, product_shop.`id_category_default`,
MAX(image_shop.`id_image`) id_image, il.`legend`, p.`ean13`, p.`upc`, cl.`link_rewrite` AS category, p.show_price, p.available_for_order, IFNULL(stock.quantity, 0) as quantity, p.customizable,
IFNULL(pa.minimal_quantity, p.minimal_quantity) as minimal_quantity, stock.out_of_stock,
product_shop.`date_add` > "' . date('Y-m-d', strtotime('-' . (Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int) Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . ' DAY')) . '" as new,
product_shop.`on_sale`, MAX(product_attribute_shop.minimal_quantity) AS product_attribute_minimal_quantity, product_shop.price AS orderprice
FROM `' . _DB_PREFIX_ . 'category_product` cp
LEFT JOIN `' . _DB_PREFIX_ . 'product` p
ON p.`id_product` = cp.`id_product`
' . Shop::addSqlAssociation('product', 'p') . (Combination::isFeatureActive() ? 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa
ON (p.`id_product` = pa.`id_product`)
' . Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1') . '
' . Product::sqlStock('p', 'product_attribute_shop', false, $context->shop) : Product::sqlStock('p', 'product', false, Context::getContext()->shop)) . '
LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl
ON (product_shop.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('cl') . ')
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
ON (p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . ')
LEFT JOIN `' . _DB_PREFIX_ . 'image` i
ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . '
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il
ON (image_shop.`id_image` = il.`id_image`
AND il.`id_lang` = ' . (int) $id_lang . ')
LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m
ON m.`id_manufacturer` = p.`id_manufacturer`
WHERE product_shop.`id_shop` = ' . (int) $context->shop->id . '
AND product_shop.id_product = ' . $productId . ' AND product_shop.`active` = 1' . ' AND product_shop.`visibility` IN ("both", "catalog")' . ($id_supplier ? ' AND p.id_supplier = ' . (int) $id_supplier : '') . ' GROUP BY product_shop.id_product';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (!$result) {
return array();
}
return Product::getProductProperties($id_lang, $result);
}
示例10: _getProductById_before
protected function _getProductById_before($productId = 0, $id_lang = null, $id_shop = null)
{
if (!$productId) {
return array();
}
if (!$id_lang) {
$id_lang = $this->context->language->id;
}
if (!$id_shop) {
$id_shop = $this->context->shop->id;
}
$product_cache_key = 'product_' . $productId . '_' . $id_lang . '_' . $id_shop;
if (_PS_CACHE_ENABLED_) {
if ($this->cache->exists($product_cache_key)) {
$product = $this->cache->get($product_cache_key);
if ($product) {
return $product;
}
}
}
//$context = Context::getContext();
$sql = 'SELECT
p.*,
product_shop.*,
stock.out_of_stock,
IFNULL(stock.quantity, 0) as quantity,
MAX(product_attribute_shop.id_product_attribute) id_product_attribute,
product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity,
pl.`description`,
pl.`description_short`,
pl.`available_now`,
pl.`available_later`,
pl.`link_rewrite`,
pl.`meta_description`,
pl.`meta_keywords`,
pl.`meta_title`,
pl.`name`,
MAX(image_shop.`id_image`) id_image,
il.`legend`,
m.`name` AS manufacturer_name,
cl.`name` AS category_default,
DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(), INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . ' DAY)) > 0 AS new,
product_shop.price AS orderprice
FROM `' . _DB_PREFIX_ . 'category_product` cp
LEFT JOIN (`' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'product_sale` ps ON ps.`id_product` = p.`id_product`)
ON (p.`id_product` = cp.`id_product`)' . Shop::addSqlAssociation('product', 'p') . ' ' . 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa
ON (p.`id_product` = pa.`id_product`)' . Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1') . ' ' . Product::sqlStock('p', 0) . '
LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl
ON (product_shop.`id_category_default` = cl.`id_category` AND cl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('cl') . ')
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . ')
LEFT JOIN `' . _DB_PREFIX_ . 'image` i
ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . '
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il
ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m
ON m.`id_manufacturer` = p.`id_manufacturer`
WHERE
product_shop.`id_shop` = ' . (int) $id_shop . '
AND product_shop.`id_product` = ' . (int) $productId . '
AND product_shop.`active` = 1
AND product_shop.`visibility` IN ("both", "catalog")';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (!$result) {
return array();
}
$result = Product::getProductProperties($id_lang, $result);
if (_PS_CACHE_ENABLED_) {
$this->cache->set($product_cache_key, $result);
}
return $result;
}
示例11: getRandomSpecial
public static function getRandomSpecial($id_lang, $beginning = false, $ending = false, Context $context = null)
{
if (!Module::isInstalled('agilemultipleseller')) {
return parent::getRandomSpecial($id_lang, $beginning, $ending, $context);
}
$agile_sql_parts = AgileSellerManager::getAdditionalSqlForProducts("p", true);
if (!$context) {
$context = Context::getContext();
}
$front = true;
if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) {
$front = false;
}
$current_date = date('Y-m-d H:i:s');
$product_reductions = Product::_getProductIdByDate(!$beginning ? $current_date : $beginning, !$ending ? $current_date : $ending, $context, true);
if ($product_reductions) {
$ids_product = ' AND (';
foreach ($product_reductions as $product_reduction) {
$ids_product .= '( product_shop.`id_product` = ' . (int) $product_reduction['id_product'] . ($product_reduction['id_product_attribute'] ? ' AND product_attribute_shop.`id_product_attribute`=' . (int) $product_reduction['id_product_attribute'] : '') . ') OR';
}
$ids_product = rtrim($ids_product, 'OR') . ')';
$groups = FrontController::getCurrentCustomerGroups();
$sql_groups = count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1';
$sql = 'SELECT product_shop.id_product, MAX(product_attribute_shop.id_product_attribute) id_product_attribute
FROM `' . _DB_PREFIX_ . 'product` p
' . Shop::addSqlAssociation('product', 'p') . '
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON (product_shop.id_product = pa.id_product)
' . Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.default_on = 1') . '
' . $agile_sql_parts['joins'] . '
WHERE product_shop.`active` = 1
' . ($ids_product ? $ids_product : '') . '
' . $agile_sql_parts['wheres'] . '
AND p.`id_product` IN (
SELECT cp.`id_product`
FROM `' . _DB_PREFIX_ . 'category_group` cg
LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`)
WHERE cg.`id_group` ' . $sql_groups . '
)
' . ($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') . '
GROUP BY product_shop.id_product
ORDER BY RAND()';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (!($id_product = $result['id_product'])) {
return false;
}
$sql = 'SELECT p.*, product_shop.*, stock.`out_of_stock` out_of_stock, pl.`description`, pl.`description_short`,
pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
p.`ean13`, p.`upc`, MAX(image_shop.`id_image`) id_image, il.`legend`,
DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(),
INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . '
DAY)) > 0 AS new
FROM `' . _DB_PREFIX_ . 'product` p
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . '
)
' . Shop::addSqlAssociation('product', 'p') . '
LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . '
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
' . Product::sqlStock('p', 0) . '
' . $agile_sql_parts['joins'] . '
WHERE p.id_product = ' . (int) $id_product . '
' . $agile_sql_parts['wheres'] . '
GROUP BY product_shop.id_product';
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (!$row) {
return false;
}
if ($result['id_product_attribute']) {
$row['id_product_attribute'] = $result['id_product_attribute'];
}
return Product::getProductProperties($id_lang, $row);
} else {
return false;
}
}
示例12: assembleProduct
public function assembleProduct(array $rawProduct)
{
$enrichedProduct = $this->addMissingProductFields($rawProduct);
return Product::getProductProperties($this->searchContext->getIdLang(), $enrichedProduct, $this->context);
}
示例13: getProductById
function getProductById($id_lang, $productId, $short = true, $getProperties = true)
{
$context = Context::getContext();
if ($short == true) {
$sql = 'SELECT p.id_product, p.ean13, p.reference, p.id_category_default, p.on_sale, p.quantity, p.minimal_quantity, p.price, p.wholesale_price, p.quantity_discount, p.show_price, p.condition, p.date_add, p.date_upd,
product_shop.on_sale, product_shop.id_category_default, product_shop.minimal_quantity, product_shop.price, product_shop.wholesale_price, product_shop.show_price, product_shop.condition, product_shop.indexed, product_shop.date_add, product_shop.date_upd,
stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, MAX(product_attribute_shop.id_product_attribute) id_product_attribute, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity,
pl.`available_later`, pl.`link_rewrite`, pl.`name`, MAX(image_shop.`id_image`) id_image,
il.`legend`, m.`name` AS manufacturer_name, cl.`name` AS category_default,
DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(),
INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . '
DAY)) > 0 AS new, product_shop.price AS orderprice';
} else {
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, MAX(product_attribute_shop.id_product_attribute) id_product_attribute, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, pl.`description`, pl.`description_short`, pl.`available_now`,
pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, MAX(image_shop.`id_image`) id_image,
il.`legend`, m.`name` AS manufacturer_name, cl.`name` AS category_default,
DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(),
INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . '
DAY)) > 0 AS new, product_shop.price AS orderprice';
}
$sql .= ' FROM `' . _DB_PREFIX_ . 'category_product` cp
LEFT JOIN `' . _DB_PREFIX_ . 'product` p
ON p.`id_product` = cp.`id_product`
' . Shop::addSqlAssociation('product', 'p') . '
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa
ON (p.`id_product` = pa.`id_product`)
' . Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1') . '
' . Product::sqlStock('p', 'product_attribute_shop', false, $context->shop) . '
LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl
ON (product_shop.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('cl') . ')
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
ON (p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . ')
LEFT JOIN `' . _DB_PREFIX_ . 'image` i
ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . '
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il
ON (image_shop.`id_image` = il.`id_image`
AND il.`id_lang` = ' . (int) $id_lang . ')
LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m
ON m.`id_manufacturer` = p.`id_manufacturer`
WHERE
product_shop.`id_shop` = ' . (int) $context->shop->id . '
AND product_shop.`id_product` = ' . $productId . '
AND product_shop.`visibility` IN ("both", "catalog")
GROUP BY product_shop.id_product';
$result = DB::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (!$result) {
return false;
}
if ($getProperties == false) {
return $result;
}
return Product::getProductProperties($id_lang, $result);
}
示例14: getTemplateVarProduct
public function getTemplateVarProduct()
{
$productSettings = $this->getProductPresentationSettings();
$product = $this->objectPresenter->present($this->product);
$product['id_product'] = (int) $this->product->id;
$product['out_of_stock'] = (int) $this->product->out_of_stock;
$product['new'] = (int) $this->product->new;
$product['id_product_attribute'] = (int) Tools::getValue('id_product_attribute');
$product['minimal_quantity'] = $this->getProductMinimalQuantity($product);
$product['quantity_wanted'] = $this->getRequiredQuantity($product);
$product_full = Product::getProductProperties($this->context->language->id, $product, $this->context);
$product_full = $this->addProductCustomizationData($product_full);
$product_full['show_quantities'] = (bool) (Configuration::get('PS_DISPLAY_QTIES') && Configuration::get('PS_STOCK_MANAGEMENT') && $this->product->quantity > 0 && $this->product->available_for_order && !Configuration::isCatalogMode());
$product_full['quantity_label'] = $this->product->quantity > 1 ? $this->trans('Items', array(), 'Shop.Theme.Catalog') : $this->trans('Item', array(), 'Shop.Theme.Catalog');
$product_full['quantity_discounts'] = $this->quantity_discounts;
if ($product_full['unit_price_ratio'] > 0) {
$unitPrice = $productSettings->include_taxes ? $product_full['price'] : $product_full['price_tax_exc'];
$product_full['unit_price'] = $unitPrice / $product_full['unit_price_ratio'];
}
$group_reduction = GroupReduction::getValueForProduct($this->product->id, (int) Group::getCurrent()->id);
if ($group_reduction === false) {
$group_reduction = Group::getReduction((int) $this->context->cookie->id_customer) / 100;
}
$product_full['customer_group_discount'] = $group_reduction;
$presenter = $this->getProductPresenter();
return $presenter->present($productSettings, $product_full, $this->context->language);
}
示例15: getAllSpecial
public function getAllSpecial($id_lang, $beginning = false, $ending = false)
{
$currentDate = date('Y-m-d');
$result = Db::getInstance()->ExecuteS('
SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`,
i.`id_image`, il.`legend`, t.`rate`
FROM `' . _DB_PREFIX_ . 'product` p
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . intval($id_lang) . ')
LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . intval($id_lang) . ')
LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON t.`id_tax` = p.`id_tax`
WHERE (`reduction_price` > 0 OR `reduction_percent` > 0)
' . ((!$beginning and !$ending) ? 'AND (`reduction_from` = `reduction_to` OR (`reduction_from` <= \'' . $currentDate . '\' AND `reduction_to` >= \'' . $currentDate . '\'))' : ($beginning ? 'AND `reduction_from` <= \'' . $beginning . '\'' : '') . ($ending ? 'AND `reduction_to` >= \'' . $ending . '\'' : '')) . '
AND p.`active` = 1
ORDER BY RAND()');
if (!$result) {
return false;
}
foreach ($result as $row) {
$rows[] = Product::getProductProperties($id_lang, $row);
}
return $rows;
}