本文整理汇总了PHP中Pack::getItemTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Pack::getItemTable方法的具体用法?PHP Pack::getItemTable怎么用?PHP Pack::getItemTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pack
的用法示例。
在下文中一共展示了Pack::getItemTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getProductProperties
public static function getProductProperties($id_lang, $row, Context $context = null)
{
if (!$row['id_product']) {
return false;
}
if ($context == null) {
$context = Context::getContext();
}
// Product::getDefaultAttribute is only called if id_product_attribute is missing from the SQL query at the origin of it:
// consider adding it in order to avoid unnecessary queries
$row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']);
if (Combination::isFeatureActive() && (!isset($row['id_product_attribute']) || !$row['id_product_attribute']) && (isset($row['cache_default_attribute']) && ($ipa_default = $row['cache_default_attribute']) !== null || ($ipa_default = Product::getDefaultAttribute($row['id_product'], !$row['allow_oosp'])))) {
$row['id_product_attribute'] = $ipa_default;
}
if (!Combination::isFeatureActive() || !isset($row['id_product_attribute'])) {
$row['id_product_attribute'] = 0;
}
// Tax
$usetax = Tax::excludeTaxeOption();
$cache_key = $row['id_product'] . '-' . $row['id_product_attribute'] . '-' . $id_lang . '-' . (int) $usetax;
if (isset($row['id_product_pack'])) {
$cache_key .= '-pack' . $row['id_product_pack'];
}
if (isset(self::$producPropertiesCache[$cache_key])) {
return self::$producPropertiesCache[$cache_key];
}
// Datas
$row['category'] = Category::getLinkRewrite((int) $row['id_category_default'], (int) $id_lang);
$row['link'] = $context->link->getProductLink((int) $row['id_product'], $row['link_rewrite'], $row['category'], $row['ean13']);
$row['attribute_price'] = 0;
if (isset($row['id_product_attribute']) && $row['id_product_attribute']) {
$row['attribute_price'] = (double) Product::getProductAttributePrice($row['id_product_attribute']);
}
$row['price_tax_exc'] = Product::getPriceStatic((int) $row['id_product'], false, isset($row['id_product_attribute']) && !empty($row['id_product_attribute']) ? (int) $row['id_product_attribute'] : null, self::$_taxCalculationMethod == PS_TAX_EXC ? 2 : 6);
if (self::$_taxCalculationMethod == PS_TAX_EXC) {
$row['price_tax_exc'] = Tools::ps_round($row['price_tax_exc'], 2);
$row['price'] = Product::getPriceStatic((int) $row['id_product'], true, isset($row['id_product_attribute']) && !empty($row['id_product_attribute']) ? (int) $row['id_product_attribute'] : null, 6);
$row['price_without_reduction'] = Product::getPriceStatic((int) $row['id_product'], false, isset($row['id_product_attribute']) && !empty($row['id_product_attribute']) ? (int) $row['id_product_attribute'] : null, 2, null, false, false);
} else {
$row['price'] = Tools::ps_round(Product::getPriceStatic((int) $row['id_product'], true, isset($row['id_product_attribute']) && !empty($row['id_product_attribute']) ? (int) $row['id_product_attribute'] : null, 2), 2);
$row['price_without_reduction'] = Product::getPriceStatic((int) $row['id_product'], true, isset($row['id_product_attribute']) && !empty($row['id_product_attribute']) ? (int) $row['id_product_attribute'] : null, 6, null, false, false);
}
$row['reduction'] = Product::getPriceStatic((int) $row['id_product'], (bool) $usetax, (int) $row['id_product_attribute'], 6, null, true, true, 1, true, null, null, null, $specific_prices);
$row['specific_prices'] = $specific_prices;
if ($row['id_product_attribute']) {
$row['quantity_all_versions'] = $row['quantity'];
$row['quantity'] = Product::getQuantity((int) $row['id_product'], $row['id_product_attribute'], isset($row['cache_is_pack']) ? $row['cache_is_pack'] : null);
} else {
$row['quantity'] = Product::getQuantity((int) $row['id_product']);
}
$row['id_image'] = Product::defineProductImage($row, $id_lang);
$row['features'] = Product::getFrontFeaturesStatic((int) $id_lang, $row['id_product']);
$row['attachments'] = array();
if (!isset($row['cache_has_attachments']) || $row['cache_has_attachments']) {
$row['attachments'] = Product::getAttachmentsStatic((int) $id_lang, $row['id_product']);
}
$row['virtual'] = !isset($row['is_virtual']) || $row['is_virtual'] ? 1 : 0;
// Pack management
$row['pack'] = !isset($row['cache_is_pack']) ? Pack::isPack($row['id_product']) : (int) $row['cache_is_pack'];
$row['packItems'] = $row['pack'] ? Pack::getItemTable($row['id_product'], $id_lang) : array();
$row['nopackprice'] = $row['pack'] ? Pack::noPackPrice($row['id_product']) : 0;
if ($row['pack'] && !Pack::isInStock($row['id_product'])) {
$row['quantity'] = 0;
}
self::$producPropertiesCache[$cache_key] = $row;
return self::$producPropertiesCache[$cache_key];
}
示例2: initContent
//.........这里部分代码省略.........
if (!isset($decoration->areasimp->ItemNumber)) {
$decoration = $decoration->areasimp;
}
foreach ($decoration as $deco) {
$decoration_list .= $deco->TecnicaFull . ', ';
}
$decoration_list = substr($decoration_list, 0, -2);
if ($this->product->quick_quote != '') {
$quote = json_decode($this->product->quick_quote);
//var_dump($this->product->quick_quote);
foreach ($quote->PricesArray->Prices as $price) {
$quote_table .= "<tr><td>" . $price->Piezas;
$precio = explode('.', $price->Precio);
$precio_imp = explode('.', $price->PrecioImp);
if (intval($price->Piezas) < 10) {
$quote_table .= " Muestra";
} else {
$quote_table .= " Piezas";
}
$quote_table .= "</td>";
$quote_table .= "<td>\$" . $precio[0] . "." . substr($precio[1], 0, 2) . "</td>";
$quote_table .= "<td>\$" . $precio_imp[0] . "." . substr($precio_imp[1], 0, 2) . "</td></tr>";
}
}
$link = new Link();
$productUrl = $link->getProductLink($this->product);
$margin = Configuration::get('PROFIT_MARGIN');
$price_type = Configuration::get('PRODUCT_DYNAMIC_PRICE');
if (isset($margin) && $price_type == 1) {
$margin = floatval($margin) / 100;
$margin = 1 - $margin;
$this->product->base_price = $this->product->base_price / $margin;
}
if (Pack::isPack((int) $this->product->id) && !Pack::isInStock((int) $this->product->id)) {
$this->product->quantity = 0;
}
$this->product->description = $this->transformDescriptionWithImg($this->product->description);
// Assign to the template the id of the virtual product. "0" if the product is not downloadable.
$this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
$this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
if (Tools::isSubmit('submitCustomizedDatas')) {
// If cart has not been saved, we need to do it so that customization fields can have an id_cart
// We check that the cookie exists first to avoid ghost carts
if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
$this->context->cart->add();
$this->context->cookie->id_cart = (int) $this->context->cart->id;
}
$this->pictureUpload();
$this->textRecord();
$this->formTargetFormat();
} else {
if (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.');
}
}
$pictures = array();
$text_fields = array();
if ($this->product->customizable) {
$files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
foreach ($files as $file) {
$pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
}
$texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
foreach ($texts as $text_field) {
$text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
}
}
$this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
$this->product->customization_required = false;
$customizationFields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false;
if (is_array($customizationFields)) {
foreach ($customizationFields as $customizationField) {
if ($this->product->customization_required = $customizationField['required']) {
break;
}
}
}
// Assign template vars related to the category + execute hooks related to the category
$this->assignCategory();
// Assign template vars related to the price and tax
$this->assignPriceAndTax();
// Assign template vars related to the images
$this->assignImages();
// Assign attribute groups to the template
$this->assignAttributesGroups();
// Assign attributes combinations to the template
$this->assignAttributesCombinations();
// Pack management
$pack_items = $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
$this->context->smarty->assign('packItems', $pack_items);
$this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
if (isset($this->category->id) && $this->category->id) {
$return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
} else {
$return_link = 'javascript: history.back();';
}
$this->context->smarty->assign(array('stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => $customizationFields, 'accessories' => $this->product->getAccessories($this->context->language->id), 'return_link' => $return_link, 'product' => $this->product, 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => $this->product->cache_has_attachments ? $this->product->getAttachments($this->context->language->id) : array(), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons', array('product' => $this->product)), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab', array('product' => $this->product)), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent', array('product' => $this->product)), 'HOOK_PRODUCT_CONTENT' => Hook::exec('displayProductContent', array('product' => $this->product)), 'HOOK_PRODUCT_FILE_CONTENT' => Hook::exec('productFileContent', array('product' => $this->product)), 'HOOK_PRODUCT_FILE' => Hook::exec('productFile', array('product' => $this->product)), 'HOOK_CUSTOM_QUOTE' => Hook::exec('displayProductcustomquote', array('product' => $this->product, 'customizationFields' => $customizationFields)), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'currencySign' => $this->context->currency->sign, 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'quote_table_detail' => $quote_table, 'inventory' => $inventory, 'decoration_list' => $decoration_list, 'product_url' => $productUrl, 'body_classes' => array($this->php_self . '-' . $this->product->id, $this->php_self . '-' . $this->product->link_rewrite, 'category-' . (isset($this->category) ? $this->category->id : ''), 'category-' . (isset($this->category) ? $this->category->getFieldByLang('link_rewrite') : '')), 'display_discount_price' => Configuration::get('PS_DISPLAY_DISCOUNT_PRICE')));
}
$this->setTemplate(_PS_THEME_DIR_ . 'product.tpl');
}
示例3: getProductProperties
public static function getProductProperties($id_lang, $row, Context $context = null)
{
Hook::exec('actionGetProductPropertiesBefore', ['id_lang' => $id_lang, 'product' => $row, 'context' => $context]);
if (!$row['id_product']) {
return false;
}
if ($context == null) {
$context = Context::getContext();
}
$id_product_attribute = $row['id_product_attribute'] = !empty($row['id_product_attribute']) ? (int) $row['id_product_attribute'] : null;
// Product::getDefaultAttribute is only called if id_product_attribute is missing from the SQL query at the origin of it:
// consider adding it in order to avoid unnecessary queries
$row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']);
if (Combination::isFeatureActive() && $id_product_attribute === null && (isset($row['cache_default_attribute']) && ($ipa_default = $row['cache_default_attribute']) !== null || ($ipa_default = Product::getDefaultAttribute($row['id_product'], !$row['allow_oosp'])))) {
$id_product_attribute = $row['id_product_attribute'] = $ipa_default;
}
if (!Combination::isFeatureActive() || !isset($row['id_product_attribute'])) {
$id_product_attribute = $row['id_product_attribute'] = 0;
}
// Tax
$usetax = !Tax::excludeTaxeOption();
$cache_key = $row['id_product'] . '-' . $id_product_attribute . '-' . $id_lang . '-' . (int) $usetax;
if (isset($row['id_product_pack'])) {
$cache_key .= '-pack' . $row['id_product_pack'];
}
if (isset(self::$producPropertiesCache[$cache_key])) {
return array_merge($row, self::$producPropertiesCache[$cache_key]);
}
// Datas
$row['category'] = Category::getLinkRewrite((int) $row['id_category_default'], (int) $id_lang);
$row['category_name'] = Db::getInstance()->getValue('SELECT name FROM ' . _DB_PREFIX_ . 'category_lang WHERE id_shop = ' . (int) $context->shop->id . ' AND id_lang = ' . (int) $id_lang . ' AND id_category = ' . (int) $row['id_category_default']);
$row['link'] = $context->link->getProductLink((int) $row['id_product'], $row['link_rewrite'], $row['category'], $row['ean13']);
$row['attribute_price'] = 0;
if ($id_product_attribute) {
$row['attribute_price'] = (double) Combination::getPrice($id_product_attribute);
}
if (isset($row['quantity_wanted'])) {
// 'quantity_wanted' may very well be zero even if set
$quantity = max((int) $row['minimal_quantity'], (int) $row['quantity_wanted']);
} else {
$quantity = (int) $row['minimal_quantity'];
}
$row['price_tax_exc'] = Product::getPriceStatic((int) $row['id_product'], false, $id_product_attribute, self::$_taxCalculationMethod == PS_TAX_EXC ? 2 : 6, null, false, true, $quantity);
if (self::$_taxCalculationMethod == PS_TAX_EXC) {
$row['price_tax_exc'] = Tools::ps_round($row['price_tax_exc'], 2);
$row['price'] = Product::getPriceStatic((int) $row['id_product'], true, $id_product_attribute, 6, null, false, true, $quantity);
$row['price_without_reduction'] = Product::getPriceStatic((int) $row['id_product'], false, $id_product_attribute, 2, null, false, false, $quantity);
} else {
$row['price'] = Tools::ps_round(Product::getPriceStatic((int) $row['id_product'], true, $id_product_attribute, 6, null, false, true, $quantity), (int) Configuration::get('PS_PRICE_DISPLAY_PRECISION'));
$row['price_without_reduction'] = Product::getPriceStatic((int) $row['id_product'], true, $id_product_attribute, 6, null, false, false, $quantity);
}
$row['reduction'] = Product::getPriceStatic((int) $row['id_product'], (bool) $usetax, $id_product_attribute, 6, null, true, true, $quantity, true, null, null, null, $specific_prices);
$row['specific_prices'] = $specific_prices;
$row['quantity'] = Product::getQuantity((int) $row['id_product'], 0, isset($row['cache_is_pack']) ? $row['cache_is_pack'] : null);
$row['quantity_all_versions'] = $row['quantity'];
if ($row['id_product_attribute']) {
$row['quantity'] = Product::getQuantity((int) $row['id_product'], $id_product_attribute, isset($row['cache_is_pack']) ? $row['cache_is_pack'] : null);
$row['available_date'] = Product::getAvailableDate((int) $row['id_product'], $id_product_attribute);
}
$row['id_image'] = Product::defineProductImage($row, $id_lang);
$row['features'] = Product::getFrontFeaturesStatic((int) $id_lang, $row['id_product']);
$row['attachments'] = array();
if (!isset($row['cache_has_attachments']) || $row['cache_has_attachments']) {
$row['attachments'] = Product::getAttachmentsStatic((int) $id_lang, $row['id_product']);
}
$row['virtual'] = !isset($row['is_virtual']) || $row['is_virtual'] ? 1 : 0;
// Pack management
$row['pack'] = !isset($row['cache_is_pack']) ? Pack::isPack($row['id_product']) : (int) $row['cache_is_pack'];
$row['packItems'] = $row['pack'] ? Pack::getItemTable($row['id_product'], $id_lang) : array();
$row['nopackprice'] = $row['pack'] ? Pack::noPackPrice($row['id_product']) : 0;
if ($row['pack'] && !Pack::isInStock($row['id_product'])) {
$row['quantity'] = 0;
}
$row['customization_required'] = false;
if (isset($row['customizable']) && $row['customizable'] && Customization::isFeatureActive()) {
if (count(Product::getRequiredCustomizableFieldsStatic((int) $row['id_product']))) {
$row['customization_required'] = true;
}
}
$attributes = Product::getAttributesParams($row['id_product'], $row['id_product_attribute']);
foreach ($attributes as $attribute) {
$row['attributes'][$attribute['id_attribute_group']] = $attribute;
}
$row = Product::getTaxesInformations($row, $context);
$row['ecotax_rate'] = (double) Tax::getProductEcotaxRate($context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
Hook::exec('actionGetProductPropertiesAfter', ['id_lang' => $id_lang, 'product' => $row, 'context' => $context]);
$combination = new Combination($id_product_attribute);
if (0 != $combination->unit_price_impact && 0 != $row['unit_price_ratio']) {
$unitPrice = $row['price_tax_exc'] / $row['unit_price_ratio'] + $combination->unit_price_impact;
$row['unit_price_ratio'] = $row['price_tax_exc'] / $unitPrice;
}
$row['unit_price'] = $row['unit_price_ratio'] != 0 ? $row['price'] / $row['unit_price_ratio'] : 0;
self::$producPropertiesCache[$cache_key] = $row;
return self::$producPropertiesCache[$cache_key];
}
示例4: process
//.........这里部分代码省略.........
$ecotaxTaxAmount = Tools::ps_round($this->product->ecotax, 2);
if (Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX')) {
$ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2);
}
self::$smarty->assign(array('quantity_discounts' => $this->formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int) $this->product->id, (int) Shop::getCurrentShop(), (int) self::$cookie->id_currency, $id_country, $id_group), $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false), (double) $tax), 'product' => $this->product, 'ecotax_tax_inc' => $ecotaxTaxAmount, 'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2), 'ecotaxTax_rate' => $ecotax_rate, 'homeSize' => Image::getSize('home'), 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, self::$cookie->id_lang), 'token' => Tools::getToken(false), 'productPriceWithoutEcoTax' => (double) $productPriceWithoutEcoTax, 'features' => $features, 'attachments' => $attachments, 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'group_reduction' => $group_reduction, 'col_img_dir' => _PS_COL_IMG_DIR_));
self::$smarty->assign(array('HOOK_EXTRA_LEFT' => Module::hookExec('extraLeft'), 'HOOK_EXTRA_RIGHT' => Module::hookExec('extraRight'), 'HOOK_PRODUCT_OOS' => Hook::productOutOfStock($this->product), 'HOOK_PRODUCT_FOOTER' => Hook::productFooter($this->product, $category), 'HOOK_PRODUCT_ACTIONS' => Module::hookExec('productActions'), 'HOOK_PRODUCT_TAB' => Module::hookExec('productTab'), 'HOOK_PRODUCT_TAB_CONTENT' => Module::hookExec('productTabContent')));
$images = $this->product->getImages((int) self::$cookie->id_lang);
$productImages = array();
foreach ($images as $k => $image) {
if ($image['cover']) {
self::$smarty->assign('mainImage', $images[0]);
$cover = $image;
$cover['id_image'] = Configuration::get('PS_LEGACY_IMAGES') ? $this->product->id . '-' . $image['id_image'] : $image['id_image'];
$cover['id_image_only'] = (int) $image['id_image'];
}
$productImages[(int) $image['id_image']] = $image;
}
if (!isset($cover)) {
$cover = array('id_image' => Language::getIsoById(self::$cookie->id_lang) . '-default', 'legend' => 'No picture', 'title' => 'No picture');
}
$size = Image::getSize('large');
self::$smarty->assign(array('cover' => $cover, 'imgWidth' => (int) $size['width'], 'mediumSize' => Image::getSize('medium'), 'largeSize' => Image::getSize('large'), 'accessories' => $this->product->getAccessories((int) self::$cookie->id_lang)));
if (count($productImages)) {
self::$smarty->assign('images', $productImages);
}
/* Attributes / Groups & colors */
$colors = array();
$attributesGroups = $this->product->getAttributesGroups((int) self::$cookie->id_lang);
// @todo (RM) should only get groups and not all declination ?
if (is_array($attributesGroups) and $attributesGroups) {
$groups = array();
$combinationImages = $this->product->getCombinationImages((int) self::$cookie->id_lang);
foreach ($attributesGroups as $k => $row) {
/* Color management */
if ((isset($row['attribute_color']) and $row['attribute_color'] or file_exists(_PS_COL_IMG_DIR_ . $row['id_attribute'] . '.jpg')) and $row['id_attribute_group'] == $this->product->id_color_default) {
$colors[$row['id_attribute']]['value'] = $row['attribute_color'];
$colors[$row['id_attribute']]['name'] = $row['attribute_name'];
if (!isset($colors[$row['id_attribute']]['attributes_quantity'])) {
$colors[$row['id_attribute']]['attributes_quantity'] = 0;
}
$colors[$row['id_attribute']]['attributes_quantity'] += (int) $row['quantity'];
}
if (!isset($groups[$row['id_attribute_group']])) {
$groups[$row['id_attribute_group']] = array('name' => $row['public_group_name'], 'is_color_group' => $row['is_color_group'], 'default' => -1);
}
$groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = $row['attribute_name'];
if ($row['default_on'] && $groups[$row['id_attribute_group']]['default'] == -1) {
$groups[$row['id_attribute_group']]['default'] = (int) $row['id_attribute'];
}
if (!isset($groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']])) {
$groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] = 0;
}
$groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int) $row['quantity'];
$combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name'];
$combinations[$row['id_product_attribute']]['attributes'][] = (int) $row['id_attribute'];
$combinations[$row['id_product_attribute']]['price'] = (double) $row['price'];
$combinations[$row['id_product_attribute']]['ecotax'] = (double) $row['ecotax'];
$combinations[$row['id_product_attribute']]['weight'] = (double) $row['weight'];
$combinations[$row['id_product_attribute']]['quantity'] = (int) $row['quantity'];
$combinations[$row['id_product_attribute']]['reference'] = $row['reference'];
$combinations[$row['id_product_attribute']]['unit_impact'] = $row['unit_price_impact'];
$combinations[$row['id_product_attribute']]['minimal_quantity'] = $row['minimal_quantity'];
$combinations[$row['id_product_attribute']]['id_image'] = isset($combinationImages[$row['id_product_attribute']][0]['id_image']) ? $combinationImages[$row['id_product_attribute']][0]['id_image'] : -1;
}
//wash attributes list (if some attributes are unavailables and if allowed to wash it)
if (!Product::isAvailableWhenOutOfStock($this->product->out_of_stock) && Configuration::get('PS_DISP_UNAVAILABLE_ATTR') == 0) {
foreach ($groups as &$group) {
foreach ($group['attributes_quantity'] as $key => &$quantity) {
if (!$quantity) {
unset($group['attributes'][$key]);
}
}
}
foreach ($colors as $key => $color) {
if (!$color['attributes_quantity']) {
unset($colors[$key]);
}
}
}
foreach ($groups as &$group) {
natcasesort($group['attributes']);
}
foreach ($combinations as $id_product_attribute => $comb) {
$attributeList = '';
foreach ($comb['attributes'] as $id_attribute) {
$attributeList .= '\'' . (int) $id_attribute . '\',';
}
$attributeList = rtrim($attributeList, ',');
$combinations[$id_product_attribute]['list'] = $attributeList;
}
self::$smarty->assign(array('groups' => $groups, 'combinaisons' => $combinations, 'combinations' => $combinations, 'colors' => (sizeof($colors) and $this->product->id_color_default) ? $colors : false, 'combinationImages' => $combinationImages));
}
self::$smarty->assign(array('no_tax' => Tax::excludeTaxeOption() or !Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), 'customizationFields' => $this->product->customizable ? $this->product->getCustomizationFields((int) self::$cookie->id_lang) : false));
// Pack management
self::$smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, (int) self::$cookie->id_lang, true) : array());
self::$smarty->assign('packs', Pack::getPacksTable($this->product->id, (int) self::$cookie->id_lang, true, 1));
}
}
self::$smarty->assign(array('ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'categories' => Category::getHomeCategories((int) self::$cookie->id_lang), 'have_image' => isset($cover) ? (int) $cover['id_image'] : false, 'tax_enabled' => Configuration::get('PS_TAX'), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'ecotax' => !sizeof($this->errors) and $this->product->ecotax > 0 ? Tools::convertPrice((double) $this->product->ecotax) : 0, 'currencySign' => $currency->sign, 'currencyRate' => $currency->conversion_rate, 'currencyFormat' => $currency->format, 'currencyBlank' => $currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM')));
}
示例5: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
if (!$this->errors) {
if (Pack::isPack((int) $this->product->id) && !Pack::isInStock((int) $this->product->id)) {
$this->product->quantity = 0;
}
$this->product->description = $this->transformDescriptionWithImg($this->product->description);
// Assign to the template the id of the virtual product. "0" if the product is not downloadable.
$this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
$this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
if (Tools::isSubmit('submitCustomizedDatas')) {
// If cart has not been saved, we need to do it so that customization fields can have an id_cart
// We check that the cookie exists first to avoid ghost carts
if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
$this->context->cart->add();
$this->context->cookie->id_cart = (int) $this->context->cart->id;
}
$this->pictureUpload();
$this->textRecord();
$this->formTargetFormat();
} elseif (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.');
}
$pictures = array();
$text_fields = array();
if ($this->product->customizable) {
$files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
foreach ($files as $file) {
$pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
}
$texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
foreach ($texts as $text_field) {
$text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
}
}
$this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
$this->product->customization_required = false;
$customization_fields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false;
if (is_array($customization_fields)) {
foreach ($customization_fields as $customization_field) {
if ($this->product->customization_required = $customization_field['required']) {
break;
}
}
}
// Assign template vars related to the category + execute hooks related to the category
$this->assignCategory();
// Assign template vars related to the price and tax
$this->assignPriceAndTax();
// Assign template vars related to the images
$this->assignImages();
// Assign attribute groups to the template
$this->assignAttributesGroups();
// Assign attributes combinations to the template
$this->assignAttributesCombinations();
// Pack management
$pack_items = $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
$this->context->smarty->assign('packItems', $pack_items);
$this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
if (isset($this->category->id) && $this->category->id) {
$return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
} else {
$return_link = 'javascript: history.back();';
}
$category_id = $this->category->id;
if ($category_id === 13) {
$foundations = array();
$foundations_ids = array(28, 29, 30, 31);
foreach ($foundations_ids as $id) {
$product = new Product($id, true, $this->context->language->id);
$cover = $product->getCover($id);
$foundations[$id]['img_src'] = $this->context->link->getImageLink($product->link_rewrite, $cover['id_image'], 'large_default');
$foundations[$id]['name'] = $product->name;
$foundations[$id]['href'] = $this->context->link->getProductLink($product->id);
$combListArr = $product->getAttributeCombinations($this->context->language->id);
$foundations[$id]['combs'] = $combListArr;
$foundations[$id]['price'] = $product->price;
}
// echo '<pre>'.print_r($foundations,true).'</pre>';
$this->context->smarty->assign(array('foundations' => $foundations));
// echo '<pre>'.print_r(get_class_methods($product),true).'</pre>';
unset($product);
}
$this->context->smarty->assign(array('stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => $customization_fields, 'accessories' => $this->product->getAccessories($this->context->language->id), 'return_link' => $return_link, 'product' => $this->product, 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => $this->product->cache_has_attachments ? $this->product->getAttachments($this->context->language->id) : array(), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons', array('product' => $this->product)), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab', array('product' => $this->product)), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent', array('product' => $this->product)), 'HOOK_PRODUCT_CONTENT' => Hook::exec('displayProductContent', array('product' => $this->product)), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'body_classes' => array($this->php_self . '-' . $this->product->id, $this->php_self . '-' . $this->product->link_rewrite, 'category-' . (isset($this->category) ? $this->category->id : ''), 'category-' . (isset($this->category) ? $this->category->getFieldByLang('link_rewrite') : '')), 'display_discount_price' => Configuration::get('PS_DISPLAY_DISCOUNT_PRICE')));
}
$this->setTemplate(_PS_THEME_DIR_ . 'product.tpl');
}
示例6: getProductProperties
public static function getProductProperties($id_lang, $row)
{
if (!$row['id_product']) {
return false;
}
$row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']);
if ((!isset($row['id_product_attribute']) or !$row['id_product_attribute']) and $ipa_default = Product::getDefaultAttribute($row['id_product'], !$row['allow_oosp'])) {
$row['id_product_attribute'] = $ipa_default;
}
if (!isset($row['id_product_attribute'])) {
$row['id_product_attribute'] = 0;
}
// Tax
$usetax = true;
$tax = floatval(Tax::getApplicableTax(intval($row['id_tax']), floatval($row['rate'])));
if (Tax::excludeTaxeOption() or !$tax) {
$usetax = false;
}
$cacheKey = $row['id_product'] . '-' . $row['id_product_attribute'] . '-' . $id_lang . '-' . intval($usetax);
if (array_key_exists($cacheKey, self::$producPropertiesCache)) {
return self::$producPropertiesCache[$cacheKey];
}
// Datas
$link = new Link();
$row['category'] = Category::getLinkRewrite($row['id_category_default'], intval($id_lang));
$row['link'] = $link->getProductLink($row['id_product'], $row['link_rewrite'], $row['category'], $row['ean13']);
$row['attribute_price'] = (isset($row['id_product_attribute']) and $row['id_product_attribute']) ? floatval(Product::getProductAttributePrice($row['id_product_attribute'])) : 0;
$row['price_tax_exc'] = Product::getPriceStatic($row['id_product'], false, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? intval($row['id_product_attribute']) : NULL, 6);
if (self::$_taxCalculationMethod == PS_TAX_EXC) {
$row['price_tax_exc'] = Tools::ps_round($row['price_tax_exc'], 2);
$row['price'] = Product::getPriceStatic($row['id_product'], true, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? intval($row['id_product_attribute']) : NULL, 6);
} else {
$row['price'] = Tools::ps_round(Product::getPriceStatic($row['id_product'], true, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? intval($row['id_product_attribute']) : NULL, 6), 2);
}
$row['reduction'] = self::getReductionValue($row['reduction_price'], $row['reduction_percent'], $row['reduction_from'], $row['reduction_to'], $row['price'], $usetax, floatval($row['rate']));
$row['price_without_reduction'] = Product::getPriceStatic($row['id_product'], true, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? intval($row['id_product_attribute']) : NULL, 6, NULL, false, false);
$row['quantity'] = Product::getQuantity($row['id_product']);
$row['id_image'] = Product::defineProductImage($row);
$row['features'] = Product::getFrontFeaturesStatic(intval($id_lang), $row['id_product']);
$row['attachments'] = Product::getAttachmentsStatic(intval($id_lang), $row['id_product']);
$row['pack'] = Pack::isPack($row['id_product']);
$row['packItems'] = $row['pack'] ? Pack::getItemTable($row['id_product'], $id_lang) : array();
$row['nopackprice'] = $row['pack'] ? Pack::noPackPrice($row['id_product']) : 0;
self::$producPropertiesCache[$cacheKey] = $row;
return self::$producPropertiesCache[$cacheKey];
}
示例7: initContent
/**
* Assign template vars related to page content.
*
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
if (!$this->errors) {
if (Pack::isPack((int) $this->product->id) && !Pack::isInStock((int) $this->product->id)) {
$this->product->quantity = 0;
}
$this->product->description = $this->transformDescriptionWithImg($this->product->description);
$priceDisplay = Product::getTaxCalculationMethod((int) $this->context->cookie->id_customer);
$productPrice = 0;
$productPriceWithoutReduction = 0;
if (!$priceDisplay || $priceDisplay == 2) {
$productPrice = $this->product->getPrice(true, null, 6);
$productPriceWithoutReduction = $this->product->getPriceWithoutReduct(false, null);
} elseif ($priceDisplay == 1) {
$productPrice = $this->product->getPrice(false, null, 6);
$productPriceWithoutReduction = $this->product->getPriceWithoutReduct(true, null);
}
if (Tools::isSubmit('submitCustomizedData')) {
// If cart has not been saved, we need to do it so that customization fields can have an id_cart
// We check that the cookie exists first to avoid ghost carts
if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
$this->context->cart->add();
$this->context->cookie->id_cart = (int) $this->context->cart->id;
}
$this->pictureUpload();
$this->textRecord();
} elseif (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
$this->errors[] = $this->trans('An error occurred while deleting the selected picture.', array(), 'Shop.Notifications.Error');
}
$pictures = array();
$text_fields = array();
if ($this->product->customizable) {
$files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
foreach ($files as $file) {
$pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
}
$texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
foreach ($texts as $text_field) {
$text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
}
}
$this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
$this->product->customization_required = false;
$customization_fields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false;
if (is_array($customization_fields)) {
foreach ($customization_fields as &$customization_field) {
if ($customization_field['type'] == 0) {
$customization_field['key'] = 'pictures_' . $this->product->id . '_' . $customization_field['id_customization_field'];
} elseif ($customization_field['type'] == 1) {
$customization_field['key'] = 'textFields_' . $this->product->id . '_' . $customization_field['id_customization_field'];
}
}
unset($customization_field);
}
// Assign template vars related to the category + execute hooks related to the category
$this->assignCategory();
// Assign template vars related to the price and tax
$this->assignPriceAndTax();
// Assign attributes combinations to the template
$this->assignAttributesCombinations();
// Pack management
$pack_items = Pack::isPack($this->product->id) ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
$assembler = new ProductAssembler($this->context);
$presenter = new ProductListingPresenter(new ImageRetriever($this->context->link), $this->context->link, new PriceFormatter(), new ProductColorsRetriever(), $this->getTranslator());
$presentationSettings = $this->getProductPresentationSettings();
$presentedPackItems = array();
foreach ($pack_items as $item) {
$presentedPackItems[] = $presenter->present($this->getProductPresentationSettings(), $assembler->assembleProduct($item), $this->context->language);
}
$this->context->smarty->assign('packItems', $presentedPackItems);
$this->context->smarty->assign('noPackPrice', $this->product->getNoPackPrice());
$this->context->smarty->assign('displayPackPrice', $pack_items && $productPrice < $this->product->getNoPackPrice() ? true : false);
$this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
$accessories = $this->product->getAccessories($this->context->language->id);
if (is_array($accessories)) {
foreach ($accessories as &$accessory) {
$accessory = $presenter->present($presentationSettings, Product::getProductProperties($this->context->language->id, $accessory, $this->context), $this->context->language);
}
unset($accessory);
}
if ($this->product->customizable) {
$customization_datas = $this->context->cart->getProductCustomization($this->product->id, null, true);
}
$product_for_template = $this->getTemplateVarProduct();
$this->context->smarty->assign(array('priceDisplay' => $priceDisplay, 'productPriceWithoutReduction' => $productPriceWithoutReduction, 'customizationFields' => $customization_fields, 'id_customization' => empty($customization_datas) ? null : $customization_datas[0]['id_customization'], 'accessories' => $accessories, 'product' => $product_for_template, 'displayUnitPrice' => !empty($this->product->unity) && $this->product->unit_price_ratio > 0.0 ? true : false, 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id)));
// Assign attribute groups to the template
$this->assignAttributesGroups($product_for_template);
}
}
示例8: process
//.........这里部分代码省略.........
}
foreach ($groups as &$group) {
natcasesort($group['attributes']);
}
foreach ($combinations as $id_product_attribute => $comb) {
$attributeList = '';
foreach ($comb['attributes'] as $id_attribute) {
$attributeList .= '\'' . (int) $id_attribute . '\',';
}
$attributeList = rtrim($attributeList, ',');
$combinations[$id_product_attribute]['list'] = $attributeList;
}
self::$smarty->assign(array('groups' => $groups, 'combinaisons' => $combinations, 'combinations' => $combinations, 'colors' => (sizeof($colors) and $this->product->id_color_default) ? $colors : false, 'combinationImages' => $combinationImages));
}
if ((int) Tools::getValue('pp') == 1) {
$time72 = time();
echo 'time72: ' . $time72;
}
//$newProducts = Product::getNewProducts((int)(self::$cookie->id_lang), 0, 10, false, 'date_add', 'desc');
/*$categoryProducts = $this->getRandomCatProducts();
self::$smarty->assign('cat_products', $categoryProducts);*/
//$brandProducts = $this->getRandomBrandProducts();
//self::$smarty->assign('brand_products', $brandProducts);
if ((int) Tools::getValue('pp') == 1) {
$time73 = time();
echo ' time73: ' . $time73;
}
self::$smarty->assign(array('no_tax' => Tax::excludeTaxeOption() or !Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), 'customizationFields' => $this->product->getCustomizationFields((int) self::$cookie->id_lang)));
if ((int) Tools::getValue('pp') == 1) {
$time74 = time();
echo 'time74: ' . $time74;
}
// Pack management
self::$smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, (int) self::$cookie->id_lang, true) : array());
self::$smarty->assign('packs', Pack::getPacksTable($this->product->id, (int) self::$cookie->id_lang, true, 1));
if ((int) Tools::getValue('pp') == 1) {
print_r('pack done');
}
}
}
if ((int) Tools::getValue('pp') == 1) {
$time8 = time();
echo 'time8: ' . $time8;
}
if ($this->is_saree || $this->is_lehenga) {
if ($this->is_lehenga) {
self::$smarty->assign('is_lehenga', $this->is_lehenga);
}
self::$smarty->assign('as_shown', (bool) $this->product->as_shown);
/*if($blouse_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 1))
self::$smarty->assign('measurement_info', $blouse_measurements);
if($skirt_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 2))
self::$smarty->assign('skirt_measurement_info', $skirt_measurements);*/
if ((int) Tools::getValue('pp') == 1) {
$time81 = time();
echo 'time81: ' . $time81;
}
if ($this->is_saree) {
//count of all styles mapped to this product
$res = Db::getInstance()->getRow("select count(s.id_style) as style_count from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and s.style_type = 1");
$style_count = (int) $res['style_count'];
if ($style_count === 0) {
// show the default style for sarees
$style = array('id_style' => 1, 'style_image_small' => '1-small.png', 'style_name' => 'Round');
} else {
$res = Db::getInstance()->getRow("select s.id_style, s.style_name, s.style_image_small from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and s.style_type = 1 and ps.is_default = 1");
示例9: getProductProperties
public static function getProductProperties($id_lang, $row)
{
if (!$row['id_product']) {
return false;
}
// Product::getDefaultAttribute is only called if id_product_attribute is missing from the SQL query at the origin of it: consider adding it in order to avoid unnecessary queries
$row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']);
if ((!isset($row['id_product_attribute']) or !$row['id_product_attribute']) and (isset($row['cache_default_attribute']) and ($ipa_default = $row['cache_default_attribute']) !== NULL or $ipa_default = Product::getDefaultAttribute($row['id_product'], !$row['allow_oosp']))) {
$row['id_product_attribute'] = $ipa_default;
}
if (!isset($row['id_product_attribute'])) {
$row['id_product_attribute'] = 0;
}
// Tax
$usetax = Tax::excludeTaxeOption();
$cacheKey = $row['id_product'] . '-' . $row['id_product_attribute'] . '-' . $id_lang . '-' . (int) $usetax;
if (array_key_exists($cacheKey, self::$producPropertiesCache)) {
return self::$producPropertiesCache[$cacheKey];
}
// Datas mbj
$link = new Link();
$row['category'] = Category::getLinkRewrite((int) $row['id_category_default'], (int) $id_lang);
$row['link'] = $link->getProductLink((int) $row['id_product'], $row['link_rewrite'], $row['category'], $row['ean13']);
//usado link
//init
foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT p.*
FROM `' . _DB_PREFIX_ . 'product` p
INNER JOIN ' . _DB_PREFIX_ . 'product_lang pl ON p.id_product = pl.id_product
WHERE p.id_product = ' . (int) $ro1w['supplier_reference']) as $subrow) {
$row_us['id_category_default'] = $subrow['id_category_default'];
$row_us['link_rewrite'] = $subrow['link_rewrite'];
$row_us['ean13'] = $subrow['ean13'];
}
$row['category_used'] = Category::getLinkRewrite((int) $row_us['id_category_default'], (int) $id_lang);
$row['link_used'] = $link->getProductLink((int) $row['supplier_reference'], $row_us['link_rewrite'], $row['category_used'], $row_us['ean13']);
$row['link_extr'] = 'id::' . $row['id_product'];
//precio mall - distribuidor - lista - internet
foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT pa.price
FROM `' . _DB_PREFIX_ . 'product_attribute` pa
INNER JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON pa.id_product_attribute = pac.id_product_attribute
WHERE pac.id_attribute = 25 and pa.id_product = ' . (int) $row['id_product']) as $subrow) {
$row['price_distribuidor_p'] = round($subrow['price']);
}
foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT pa.price
FROM `' . _DB_PREFIX_ . 'product_attribute` pa
INNER JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON pa.id_product_attribute = pac.id_product_attribute
WHERE pac.id_attribute = 24 and pa.id_product = ' . (int) $row['id_product']) as $subrow) {
$row['price_distribuidor'] = round($subrow['price']);
}
foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT pa.price
FROM `' . _DB_PREFIX_ . 'product_attribute` pa
INNER JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON pa.id_product_attribute = pac.id_product_attribute
WHERE pac.id_attribute = 23 and pa.id_product = ' . (int) $row['id_product']) as $subrow) {
$row['price_tienda'] = round($subrow['price']);
}
foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT pa.price
FROM `' . _DB_PREFIX_ . 'product_attribute` pa
INNER JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON pa.id_product_attribute = pac.id_product_attribute
WHERE pac.id_attribute = 22 and pa.id_product = ' . (int) $row['id_product']) as $subrow) {
$row['price_mall'] = round($subrow['price']);
}
foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT pa.price
FROM `' . _DB_PREFIX_ . 'product_attribute` pa
INNER JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON pa.id_product_attribute = pac.id_product_attribute
WHERE pac.id_attribute = 21 and pa.id_product = ' . (int) $row['id_product']) as $subrow) {
$row['price_internet'] = round($subrow['price']);
}
$row['attribute_price'] = (isset($row['id_product_attribute']) and $row['id_product_attribute']) ? (double) Product::getProductAttributePrice($row['id_product_attribute']) : 0;
$row['price_tax_exc'] = Product::getPriceStatic((int) $row['id_product'], false, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : NULL, self::$_taxCalculationMethod == PS_TAX_EXC ? 2 : 6);
if (self::$_taxCalculationMethod == PS_TAX_EXC) {
$row['price_tax_exc'] = Tools::ps_round($row['price_tax_exc'], 2);
$row['price'] = Product::getPriceStatic((int) $row['id_product'], true, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : NULL, 6);
$row['price_without_reduction'] = Product::getPriceStatic((int) $row['id_product'], false, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : NULL, 2, NULL, false, false);
} else {
$row['price'] = Tools::ps_round(Product::getPriceStatic((int) $row['id_product'], true, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : NULL, 2), 2);
$row['price_without_reduction'] = Product::getPriceStatic((int) $row['id_product'], true, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : NULL, 6, NULL, false, false);
}
$row['reduction'] = Product::getPriceStatic((int) $row['id_product'], (bool) $usetax, (int) $row['id_product_attribute'], 6, NULL, true, true, 1, true, NULL, NULL, NULL, $specific_prices);
$row['specific_prices'] = $specific_prices;
if ($row['id_product_attribute']) {
$row['quantity_all_versions'] = $row['quantity'];
$row['quantity'] = Product::getQuantity((int) $row['id_product'], $row['id_product_attribute'], isset($row['cache_is_pack']) ? $row['cache_is_pack'] : NULL);
}
$row['id_image'] = Product::defineProductImage($row, $id_lang);
$row['features'] = Product::getFrontFeaturesStatic((int) $id_lang, $row['id_product']);
$row['attachments'] = (!isset($row['cache_has_attachments']) or $row['cache_has_attachments']) ? Product::getAttachmentsStatic((int) $id_lang, $row['id_product']) : array();
// Pack management
$row['pack'] = !isset($row['cache_is_pack']) ? Pack::isPack($row['id_product']) : (int) $row['cache_is_pack'];
$row['packItems'] = $row['pack'] ? Pack::getItemTable($row['id_product'], $id_lang) : array();
$row['nopackprice'] = $row['pack'] ? Pack::noPackPrice($row['id_product']) : 0;
if ($row['pack'] and !Pack::isInStock($row['id_product'])) {
$row['quantity'] = 0;
}
self::$producPropertiesCache[$cacheKey] = $row;
//.........这里部分代码省略.........
示例10: getProductsProperties
public static function getProductsProperties($id_lang, $query_result)
{
$results_array = array();
if (is_array($query_result)) {
foreach ($query_result as $row) {
if ($row2 = Product::getProductProperties($id_lang, $row)) {
if (Pack::isPack($row['id_product'])) {
$row2['is_pack'] = true;
$row2['pack_items'] = Pack::getItemTable($row['id_product'], $id_lang, true);
if (!$row2['pack_items']) {
$row2['pack_items'] = array();
}
}
$row['is_bestsaler'] = ProductSale::isBestsaler($row['id_product']);
$results_array[] = $row2;
}
}
}
return $results_array;
}
示例11: renderView
//.........这里部分代码省略.........
$shop = new Shop((int) $order->id_shop);
$this->toolbar_title .= ' - ' . sprintf($this->trans('Shop: %s', array(), 'Admin.OrdersCustomers.Feature'), $shop->name);
}
// gets warehouses to ship products, if and only if advanced stock management is activated
$warehouse_list = null;
$order_details = $order->getOrderDetailList();
foreach ($order_details as $order_detail) {
$product = new Product($order_detail['product_id']);
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management) {
$warehouses = Warehouse::getWarehousesByProductId($order_detail['product_id'], $order_detail['product_attribute_id']);
foreach ($warehouses as $warehouse) {
if (!isset($warehouse_list[$warehouse['id_warehouse']])) {
$warehouse_list[$warehouse['id_warehouse']] = $warehouse;
}
}
}
}
$payment_methods = array();
foreach (PaymentModule::getInstalledPaymentModules() as $payment) {
$module = Module::getInstanceByName($payment['name']);
if (Validate::isLoadedObject($module) && $module->active) {
$payment_methods[] = $module->displayName;
}
}
// display warning if there are products out of stock
$display_out_of_stock_warning = false;
$current_order_state = $order->getCurrentOrderState();
if (Configuration::get('PS_STOCK_MANAGEMENT') && (!Validate::isLoadedObject($current_order_state) || $current_order_state->delivery != 1 && $current_order_state->shipped != 1)) {
$display_out_of_stock_warning = true;
}
// products current stock (from stock_available)
foreach ($products as &$product) {
// Get total customized quantity for current product
$customized_product_quantity = 0;
if (is_array($product['customizedDatas'])) {
foreach ($product['customizedDatas'] as $customizationPerAddress) {
foreach ($customizationPerAddress as $customizationId => $customization) {
$customized_product_quantity += (int) $customization['quantity'];
}
}
}
$product['customized_product_quantity'] = $customized_product_quantity;
$product['current_stock'] = StockAvailable::getQuantityAvailableByProduct($product['product_id'], $product['product_attribute_id'], $product['id_shop']);
$resume = OrderSlip::getProductSlipResume($product['id_order_detail']);
$product['quantity_refundable'] = $product['product_quantity'] - $resume['product_quantity'];
$product['amount_refundable'] = $product['total_price_tax_excl'] - $resume['amount_tax_excl'];
$product['amount_refundable_tax_incl'] = $product['total_price_tax_incl'] - $resume['amount_tax_incl'];
$product['amount_refund'] = Tools::displayPrice($resume['amount_tax_incl'], $currency);
$product['refund_history'] = OrderSlip::getProductSlipDetail($product['id_order_detail']);
$product['return_history'] = OrderReturn::getProductReturnDetail($product['id_order_detail']);
// if the current stock requires a warning
if ($product['current_stock'] <= 0 && $display_out_of_stock_warning) {
$this->displayWarning($this->trans('This product is out of stock: ', array(), 'Admin.OrdersCustomers.Notification') . ' ' . $product['product_name']);
}
if ($product['id_warehouse'] != 0) {
$warehouse = new Warehouse((int) $product['id_warehouse']);
$product['warehouse_name'] = $warehouse->name;
$warehouse_location = WarehouseProductLocation::getProductLocation($product['product_id'], $product['product_attribute_id'], $product['id_warehouse']);
if (!empty($warehouse_location)) {
$product['warehouse_location'] = $warehouse_location;
} else {
$product['warehouse_location'] = false;
}
} else {
$product['warehouse_name'] = '--';
$product['warehouse_location'] = false;
}
}
// Package management for order
foreach ($products as &$product) {
$pack_items = $product['cache_is_pack'] ? Pack::getItemTable($product['id_product'], $this->context->language->id, true) : array();
foreach ($pack_items as &$pack_item) {
$pack_item['current_stock'] = StockAvailable::getQuantityAvailableByProduct($pack_item['id_product'], $pack_item['id_product_attribute'], $pack_item['id_shop']);
// if the current stock requires a warning
if ($product['current_stock'] <= 0 && $display_out_of_stock_warning) {
$this->displayWarning($this->trans('This product, included in package (' . $product['product_name'] . ') is out of stock: ', array(), 'Admin.OrdersCustomers.Notification') . ' ' . $pack_item['product_name']);
}
$this->setProductImageInformations($pack_item);
if ($pack_item['image'] != null) {
$name = 'product_mini_' . (int) $pack_item['id_product'] . (isset($pack_item['id_product_attribute']) ? '_' . (int) $pack_item['id_product_attribute'] : '') . '.jpg';
// generate image cache, only for back office
$pack_item['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $pack_item['image']->getExistingImgPath() . '.jpg', $name, 45, 'jpg');
if (file_exists(_PS_TMP_IMG_DIR_ . $name)) {
$pack_item['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name);
} else {
$pack_item['image_size'] = false;
}
}
}
$product['pack_items'] = $pack_items;
}
$gender = new Gender((int) $customer->id_gender, $this->context->language->id);
$history = $order->getHistory($this->context->language->id);
foreach ($history as &$order_state) {
$order_state['text-color'] = Tools::getBrightness($order_state['color']) < 128 ? 'white' : 'black';
}
// Smarty assign
$this->tpl_view_vars = array('order' => $order, 'cart' => new Cart($order->id_cart), 'customer' => $customer, 'gender' => $gender, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'addresses' => array('delivery' => $addressDelivery, 'deliveryState' => isset($deliveryState) ? $deliveryState : null, 'invoice' => $addressInvoice, 'invoiceState' => isset($invoiceState) ? $invoiceState : null), 'customerStats' => $customer->getStats(), 'products' => $products, 'discounts' => $order->getCartRules(), 'orders_total_paid_tax_incl' => $order->getOrdersTotalPaid(), 'total_paid' => $order->getTotalPaid(), 'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id), 'customer_thread_message' => CustomerThread::getCustomerMessages($order->id_customer, null, $order->id), 'orderMessages' => OrderMessage::getOrderMessages($order->id_lang), 'messages' => Message::getMessagesByOrderId($order->id, true), 'carrier' => new Carrier($order->id_carrier), 'history' => $history, 'states' => OrderState::getOrderStates($this->context->language->id), 'warehouse_list' => $warehouse_list, 'sources' => ConnectionsSource::getOrderSources($order->id), 'currentState' => $order->getCurrentOrderState(), 'currency' => new Currency($order->id_currency), 'currencies' => Currency::getCurrenciesByIdShop($order->id_shop), 'previousOrder' => $order->getPreviousOrderId(), 'nextOrder' => $order->getNextOrderId(), 'current_index' => self::$currentIndex, 'carrierModuleCall' => $carrier_module_call, 'iso_code_lang' => $this->context->language->iso_code, 'id_lang' => $this->context->language->id, 'can_edit' => $this->access('edit'), 'current_id_lang' => $this->context->language->id, 'invoices_collection' => $order->getInvoicesCollection(), 'not_paid_invoices_collection' => $order->getNotPaidInvoicesCollection(), 'payment_methods' => $payment_methods, 'invoice_management_active' => Configuration::get('PS_INVOICE', null, null, $order->id_shop), 'display_warehouse' => (int) Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'), 'carrier_list' => $this->getCarrierList($order), 'recalculate_shipping_cost' => (int) Configuration::get('PS_ORDER_RECALCULATE_SHIPPING'), 'HOOK_CONTENT_ORDER' => Hook::exec('displayAdminOrderContentOrder', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_CONTENT_SHIP' => Hook::exec('displayAdminOrderContentShip', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_ORDER' => Hook::exec('displayAdminOrderTabOrder', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_SHIP' => Hook::exec('displayAdminOrderTabShip', array('order' => $order, 'products' => $products, 'customer' => $customer)));
return parent::renderView();
}
示例12: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$flag_pack = true;
if (!$this->errors) {
// if(!isset($_GET['quick_view']))
// if (Pack::isPack((int)$this->product->id) && !Pack::isInStock((int)$this->product->id))
// if (Pack::isPack((int)$this->product->id))
// $this->product->quantity = 0;
// else
// $flag_pack = false;
// else
// $flag_pack = false;
if (!Pack::isPack((int) $this->product->id)) {
$flag_pack = false;
}
$this->product->description = $this->transformDescriptionWithImg($this->product->description);
// Assign to the template the id of the virtual product. "0" if the product is not downloadable.
$this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
$this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
if (Tools::isSubmit('submitCustomizedDatas')) {
// If cart has not been saved, we need to do it so that customization fields can have an id_cart
// We check that the cookie exists first to avoid ghost carts
if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
$this->context->cart->add();
$this->context->cookie->id_cart = (int) $this->context->cart->id;
}
$this->pictureUpload();
$this->textRecord();
$this->formTargetFormat();
} else {
if (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.');
}
}
$pictures = array();
$text_fields = array();
if ($this->product->customizable) {
$files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
foreach ($files as $file) {
$pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
}
$texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
foreach ($texts as $text_field) {
$text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
}
}
$this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
// Assign template vars related to the category + execute hooks related to the category
$this->assignCategory();
// Assign template vars related to the price and tax
$this->assignPriceAndTax();
// Assign template vars related to the images
$this->assignImages();
$this->assign3dImages();
// Assign attribute groups to the template
$this->assignAttributesGroups();
// Assign attributes combinations to the template
$this->assignAttributesCombinations();
// Pack management
$pack_items = $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
if (is_array($pack_items) && count($pack_items)) {
foreach ($pack_items as &$pack_item) {
$pack_item['features'] = Product::getFrontFeaturesStatic($this->context->language->id, $pack_item['id_product']);
}
}
$this->context->smarty->assign('packItems', $pack_items);
$this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
if (isset($this->category->id) && $this->category->id) {
$return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
} else {
$return_link = 'javascript: history.back();';
}
//reviews
// $average = ProductComment::getAverageGrade((int)Tools::getValue('id_product'));
$nbComments = (int) ProductComment::getCommentNumber((int) Tools::getValue('id_product'));
$act_pack = 0;
//паки
if (!$flag_pack) {
$sql = "SELECT DISTINCT(id_product_pack) FROM " . _DB_PREFIX_ . "pack WHERE id_product_item={$this->product->id}";
$pack_products = array();
$result_packs = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (is_array($result_packs) && count($result_packs)) {
foreach ($result_packs as $k => $id_product_pack) {
$prod = new Product($id_product_pack['id_product_pack'], $this->context->language->id, true);
$cover = $prod->getCover((int) $prod->id);
if ($cover) {
$pack_products[$k]['id_image'] = $cover['id_image'];
} else {
$pack_products[$k]['id_image'] = null;
}
$price = $prod->getPrice(true, null, 2);
$price_old = $prod->getPriceWithoutReduct(false, null, 2);
if (isset($prod->specificPrice) && is_array($prod->specificPrice)) {
$pack_products[$k]['sale_percentage'] = $prod->specificPrice['reduction_type'] == 'percentage' ? $prod->specificPrice['reduction'] * 100 : $prod->specificPrice['reduction'] / $price_old * 100;
}
//.........这里部分代码省略.........
示例13: foreach
}
}
}
}
foreach ($groups as &$group) {
natcasesort($group['attributes']);
}
foreach ($combinations as $id_product_attribute => $comb) {
$attributeList = '';
foreach ($comb['attributes'] as $id_attribute) {
$attributeList .= '\'' . intval($id_attribute) . '\',';
}
$attributeList = rtrim($attributeList, ',');
$combinations[$id_product_attribute]['list'] = $attributeList;
}
$smarty->assign(array('groups' => $groups, 'combinaisons' => $combinations, 'combinations' => $combinations, 'colors' => (sizeof($colors) and $product->id_color_default) ? $colors : false, 'combinationImages' => $combinationImages));
}
}
$smarty->assign(array('no_tax' => Tax::excludeTaxeOption() or !Tax::getApplicableTax(intval($product->id_tax), 1), 'customizationFields' => $product->getCustomizationFields(intval($cookie->id_lang))));
// Pack management
$smarty->assign('packItems', Pack::getItemTable($product->id, intval($cookie->id_lang), true));
$smarty->assign('packs', Pack::getPacksTable($product->id, intval($cookie->id_lang), true, 1));
}
}
$smarty->assign(array('ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => intval(Configuration::get('PS_ORDER_OUT_OF_STOCK')), 'errors' => $errors, 'categories' => Category::getHomeCategories(intval($cookie->id_lang)), 'have_image' => Product::getCover(intval(Tools::getValue('id_product'))), 'tax_enabled' => Configuration::get('PS_TAX'), 'display_qties' => intval(Configuration::get('PS_DISPLAY_QTIES')), 'display_ht' => !Tax::excludeTaxeOption()));
if (file_exists(_PS_THEME_DIR_ . 'thickbox.tpl')) {
$smarty->display(_PS_THEME_DIR_ . 'thickbox.tpl');
}
$smarty->assign(array('currencySign' => $currency->sign, 'currencyRate' => $currency->conversion_rate, 'currencyFormat' => $currency->format, 'currencyBlank' => $currency->blank));
$smarty->display(_PS_THEME_DIR_ . 'product.tpl');
include dirname(__FILE__) . '/footer.php';
示例14: getProductProperties
public static function getProductProperties($id_lang, $row)
{
if (!$row['id_product']) {
return false;
}
// Product::getDefaultAttribute is only called if id_product_attribute is missing from the SQL query at the origin of it: consider adding it in order to avoid unnecessary queries
$row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']);
if ((!isset($row['id_product_attribute']) or !$row['id_product_attribute']) and (isset($row['cache_default_attribute']) and ($ipa_default = $row['cache_default_attribute']) !== NULL or $ipa_default = Product::getDefaultAttribute($row['id_product'], !$row['allow_oosp']))) {
$row['id_product_attribute'] = $ipa_default;
}
if (!isset($row['id_product_attribute'])) {
$row['id_product_attribute'] = 0;
}
// Tax
$usetax = Tax::excludeTaxeOption();
$cacheKey = $row['id_product'] . '-' . $row['id_product_attribute'] . '-' . $id_lang . '-' . (int) $usetax;
if (array_key_exists($cacheKey, self::$producPropertiesCache)) {
return self::$producPropertiesCache[$cacheKey];
}
// Datas
$row['category'] = Category::getLinkRewrite((int) $row['id_category_default'], (int) $id_lang);
if (!preg_match("/^1.3.*/", _PS_VERSION_)) {
// Not available in Prestashop 1.3.x
$row['reduction'] = Product::getPriceStatic((int) $row['id_product'], (bool) $usetax, (int) $row['id_product_attribute'], 6, NULL, true, true, 1, true, NULL, NULL, NULL, $specific_prices);
$row['specific_prices'] = $specific_prices;
}
if ($row['id_product_attribute']) {
$row['quantity_all_versions'] = $row['quantity'];
$row['quantity'] = Product::getQuantity((int) $row['id_product'], $row['id_product_attribute'], isset($row['cache_is_pack']) ? $row['cache_is_pack'] : NULL);
}
$row['id_image'] = Product::defineProductImage($row, $id_lang);
$row['features'] = Product::getFrontFeaturesStatic((int) $id_lang, $row['id_product']);
// Pack management
$row['pack'] = !isset($row['cache_is_pack']) ? Pack::isPack($row['id_product']) : (int) $row['cache_is_pack'];
$row['packItems'] = $row['pack'] ? Pack::getItemTable($row['id_product'], $id_lang) : array();
$row['nopackprice'] = $row['pack'] ? Pack::noPackPrice($row['id_product']) : 0;
if ($row['pack'] and !Pack::isInStock($row['id_product'])) {
$row['quantity'] = 0;
}
$sql_combination = '
SELECT pa.id_product_attribute, pa.price, pa.quantity, pa.id_product
FROM `' . _DB_PREFIX_ . 'product` p
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON (p.`id_product` = pa.`id_product`)
WHERE p.`id_product` =' . $row['id_product'];
$result_combination = ProductExtended::getDbInstance()->ExecuteS($sql_combination);
$row['combinations'] = array();
if ($result_combination) {
foreach ($result_combination as $combination) {
$combination['attributes'] = array();
/* New combinations system Prestashop 1.5.x */
if (!preg_match("/^1.(3|4).*/", _PS_VERSION_)) {
$combination['quantity'] = StockAvailable::getQuantityAvailableByProduct($row['id_product'], $combination['id_product_attribute']);
}
if (isset($combination['id_product_attribute'])) {
$sql_attribute = '
SELECT pa.id_product_attribute, agl.id_attribute_group, al.name as name_value, agl.name as name_option
FROM `' . _DB_PREFIX_ . 'product_attribute` pa
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` pac ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
LEFT JOIN `' . _DB_PREFIX_ . 'attribute` a ON (a.`id_attribute` = pac.`id_attribute`)
LEFT JOIN `' . _DB_PREFIX_ . 'attribute_lang` al ON (al.`id_attribute` = a.`id_attribute` AND al.`id_lang` = ' . $id_lang . ')
LEFT JOIN `' . _DB_PREFIX_ . 'attribute_group` ag ON (ag.`id_attribute_group` = a.`id_attribute_group`)
LEFT JOIN `' . _DB_PREFIX_ . 'attribute_group_lang` agl ON (agl.`id_attribute_group` = ag.`id_attribute_group` AND agl.`id_lang` = ' . $id_lang . ')
WHERE pa.`id_product_attribute` =' . $combination['id_product_attribute'];
$result_attribute = ProductExtended::getDbInstance()->ExecuteS($sql_attribute);
if ($result_attribute) {
foreach ($result_attribute as $attribute) {
array_push($combination['attributes'], $attribute);
}
}
array_push($row['combinations'], $combination);
}
}
}
$sql_image = '
SELECT DISTINCT i.*, pl.link_rewrite
FROM `' . _DB_PREFIX_ . 'product` p
LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (p.`id_product` = i.`id_product`)
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product`)
WHERE p.`id_product` =' . $row['id_product'];
$result_image = ProductExtended::getDbInstance()->ExecuteS($sql_image);
$row['images'] = array();
$lang = new Language($id_lang);
$row['url_locale'] = $lang->iso_code;
if ($result_image) {
$link = preg_match("/^1.(3|4).*/", _PS_VERSION_) ? new Link() : Context::getContext()->link;
foreach ($result_image as $image) {
if (!preg_match("/^1.3.*/", _PS_VERSION_)) {
// Image URL gives relative version using 1.3.x-
$image['image_url'] = $link->getImageLink($image['link_rewrite'], $image['id_product'] . '-' . $image['id_image']);
}
array_push($row['images'], $image);
}
}
self::$producPropertiesCache[$cacheKey] = $row;
return self::$producPropertiesCache[$cacheKey];
}
示例15: getProductProperties
public static function getProductProperties($id_lang, $row)
{
if (!$row['id_product']) {
return false;
}
// Product::getDefaultAttribute is only called if id_product_attribute is missing from the SQL query at the origin of it: consider adding it in order to avoid unnecessary queries
$row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']);
if ((!isset($row['id_product_attribute']) or !$row['id_product_attribute']) and (isset($row['cache_default_attribute']) and ($ipa_default = $row['cache_default_attribute']) !== NULL or $ipa_default = Product::getDefaultAttribute($row['id_product'], !$row['allow_oosp']))) {
$row['id_product_attribute'] = $ipa_default;
}
if (!isset($row['id_product_attribute'])) {
$row['id_product_attribute'] = 0;
}
// Tax
$usetax = Tax::excludeTaxeOption();
$cacheKey = $row['id_product'] . '-' . $row['id_product_attribute'] . '-' . $id_lang . '-' . (int) $usetax;
if (array_key_exists($cacheKey, self::$producPropertiesCache)) {
return self::$producPropertiesCache[$cacheKey];
}
// Datas
$link = new Link();
$row['category'] = Category::getLinkRewrite((int) $row['id_category_default'], (int) $id_lang);
$row['link'] = $link->getProductLink((int) $row['id_product'], $row['link_rewrite'], $row['category'], $row['ean13']);
$row['attribute_price'] = (isset($row['id_product_attribute']) and $row['id_product_attribute']) ? (double) Product::getProductAttributePrice($row['id_product_attribute']) : 0;
$row['price_tax_exc'] = Product::getPriceStatic((int) $row['id_product'], false, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : NULL, self::$_taxCalculationMethod == PS_TAX_EXC ? 2 : 6);
if (self::$_taxCalculationMethod == PS_TAX_EXC) {
$row['price_tax_exc'] = Tools::ps_round($row['price_tax_exc'], 2);
$row['price'] = Product::getPriceStatic((int) $row['id_product'], true, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : NULL, 6);
$row['price_without_reduction'] = Product::getPriceStatic((int) $row['id_product'], false, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : NULL, 2, NULL, false, false);
} else {
$row['price'] = Tools::ps_round(Product::getPriceStatic((int) $row['id_product'], true, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : NULL, 2), 2);
$row['price_without_reduction'] = Product::getPriceStatic((int) $row['id_product'], true, (isset($row['id_product_attribute']) and !empty($row['id_product_attribute'])) ? (int) $row['id_product_attribute'] : NULL, 6, NULL, false, false);
}
$row['reduction'] = Product::getPriceStatic((int) $row['id_product'], (bool) $usetax, (int) $row['id_product_attribute'], 6, NULL, true, true, 1, true, NULL, NULL, NULL, $specific_prices);
$row['specific_prices'] = $specific_prices;
if ($row['id_product_attribute']) {
$row['quantity_all_versions'] = $row['quantity'];
$row['quantity'] = Product::getQuantity((int) $row['id_product'], $row['id_product_attribute'], isset($row['cache_is_pack']) ? $row['cache_is_pack'] : NULL);
}
$row['id_image'] = Product::defineProductImage($row, $id_lang);
$row['features'] = Product::getFrontFeaturesStatic((int) $id_lang, $row['id_product']);
$row['attachments'] = (!isset($row['cache_has_attachments']) or $row['cache_has_attachments']) ? Product::getAttachmentsStatic((int) $id_lang, $row['id_product']) : array();
// Pack management
$row['pack'] = !isset($row['cache_is_pack']) ? Pack::isPack($row['id_product']) : (int) $row['cache_is_pack'];
$row['packItems'] = $row['pack'] ? Pack::getItemTable($row['id_product'], $id_lang) : array();
$row['nopackprice'] = $row['pack'] ? Pack::noPackPrice($row['id_product']) : 0;
if ($row['pack'] and !Pack::isInStock($row['id_product'])) {
$row['quantity'] = 0;
}
self::$producPropertiesCache[$cacheKey] = $row;
return self::$producPropertiesCache[$cacheKey];
}