本文整理汇总了PHP中Product::getAttributesGroups方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::getAttributesGroups方法的具体用法?PHP Product::getAttributesGroups怎么用?PHP Product::getAttributesGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product::getAttributesGroups方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findProductCombinationById
/**
* @param $combinationId
* @return null|ProductController
*/
public function findProductCombinationById($combinationId)
{
$foundCombination = null;
$combinations = $this->product->getAttributesGroups($this->context->language->id);
foreach ($combinations as $combination) {
if ((int) $combination['id_product_attribute'] === $combinationId) {
$foundCombination = $combination;
break;
}
}
return $foundCombination;
}
示例2: initGroupTable
public function initGroupTable()
{
$combinations_groups = $this->product->getAttributesGroups($this->context->language->id);
$attributes = array();
$impacts = Product::getAttributesImpacts($this->product->id);
foreach ($combinations_groups as &$combination) {
$target =& $attributes[$combination['id_attribute_group']][$combination['id_attribute']];
$target = $combination;
if (isset($impacts[$combination['id_attribute']])) {
$target['price'] = $impacts[$combination['id_attribute']]['price'];
$target['weight'] = $impacts[$combination['id_attribute']]['weight'];
}
}
$this->context->smarty->assign(array('currency_sign' => $this->context->currency->sign, 'weight_unit' => Configuration::get('PS_WEIGHT_UNIT'), 'attributes' => $attributes));
}
示例3: assignAttributesGroups
/**
* Assign template vars related to attribute groups and colors
*/
protected function assignAttributesGroups()
{
$colors = array();
$groups = array();
// @todo (RM) should only get groups and not all declination ?
$attributes_groups = $this->product->getAttributesGroups($this->context->language->id);
if (is_array($attributes_groups) && $attributes_groups) {
$combination_images = $this->product->getCombinationImages($this->context->language->id);
$combination_prices_set = array();
foreach ($attributes_groups as $k => $row) {
// Color management
if (isset($row['attribute_color']) && $row['attribute_color'] || file_exists(_PS_COL_IMG_DIR_ . $row['id_attribute'] . '.jpg')) {
$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'], 'group_type' => $row['group_type'], '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'];
if ($row['available_date'] != '0000-00-00 00:00:00' && $row['available_date'] != '0000-00-00') {
$available_date = Tools::displayDate($row['available_date'], $this->context->language->id);
} else {
$available_date = $row['available_date'];
}
$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'];
// Call getPriceStatic in order to set $combination_specific_price
if (!isset($combination_prices_set[(int) $row['id_product_attribute']])) {
Product::getPriceStatic((int) $this->product->id, false, $row['id_product_attribute'], 6, null, false, true, 1, false, null, null, null, $combination_specific_price);
$combination_prices_set[(int) $row['id_product_attribute']] = true;
$combinations[$row['id_product_attribute']]['specific_price'] = $combination_specific_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']]['available_date'] = $available_date;
if (isset($combination_images[$row['id_product_attribute']][0]['id_image'])) {
$combinations[$row['id_product_attribute']]['id_image'] = $combination_images[$row['id_product_attribute']][0]['id_image'];
} else {
$combinations[$row['id_product_attribute']]['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 ($combinations as $id_product_attribute => $comb) {
$attribute_list = '';
foreach ($comb['attributes'] as $id_attribute) {
$attribute_list .= '\'' . (int) $id_attribute . '\',';
}
$attribute_list = rtrim($attribute_list, ',');
$combinations[$id_product_attribute]['list'] = $attribute_list;
}
$this->context->smarty->assign(array('groups' => $groups, 'combinations' => $combinations, 'colors' => count($colors) ? $colors : false, 'combinationImages' => $combination_images));
}
}
示例4: getCombinations
/**
* @param Product $product
* @param int $lang id of a language
* @return array of a product declinations.
*/
private function getCombinations(Product $product, $lang)
{
$attributesGroups = $product->getAttributesGroups((int) $lang);
$combinations = array();
if ($attributesGroups && is_array($attributesGroups)) {
$combinationImages = $product->getCombinationImages((int) $lang);
foreach ($attributesGroups as $k => $row) {
$combinations[$row['id_product_attribute']]['id_combination'] = $row['id_product_attribute'];
$combinations[$row['id_product_attribute']]['attributes'][$row['id_attribute_group']] = array('name' => $row['attribute_name'], 'group_name' => $row['public_group_name'], 'id_attribute' => (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'];
if (isset($row['unit_price_impact'])) {
$combinations[$row['id_product_attribute']]['unit_impact'] = $row['unit_price_impact'];
}
$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;
}
}
return $combinations;
}
示例5: searchProducts
protected function searchProducts($search)
{
if ($products = Product::searchByName((int) $this->context->language->id, $search)) {
foreach ($products as &$product) {
$combinations = array();
$productObj = new Product((int) $product['id_product'], false, (int) $this->context->language->id);
$attributes = $productObj->getAttributesGroups((int) $this->context->language->id);
$product['formatted_price'] = Tools::displayPrice(Tools::convertPrice($product['price_tax_incl'], $this->context->currency), $this->context->currency);
foreach ($attributes as $attribute) {
if (!isset($combinations[$attribute['id_product_attribute']]['attributes'])) {
$combinations[$attribute['id_product_attribute']]['attributes'] = '';
}
$combinations[$attribute['id_product_attribute']]['attributes'] .= $attribute['attribute_name'] . ' - ';
$combinations[$attribute['id_product_attribute']]['id_product_attribute'] = $attribute['id_product_attribute'];
$combinations[$attribute['id_product_attribute']]['default_on'] = $attribute['default_on'];
if (!isset($combinations[$attribute['id_product_attribute']]['price'])) {
$price_tax_incl = Product::getPriceStatic((int) $product['id_product'], true, $attribute['id_product_attribute']);
$combinations[$attribute['id_product_attribute']]['formatted_price'] = Tools::displayPrice(Tools::convertPrice($price_tax_incl, $this->context->currency), $this->context->currency);
}
}
foreach ($combinations as &$combination) {
$combination['attributes'] = rtrim($combination['attributes'], ' - ');
}
$product['combinations'] = $combinations;
}
return array('products' => $products, 'found' => true);
} else {
return array('found' => false, 'notfound' => Tools::displayError('No product has been found.'));
}
}
示例6: getSKUs
function getSKUs($products)
{
$skus = array();
foreach ($products as $product) {
$id_product = $product['id_product'];
$divaProduct = new Product($id_product, true, 1);
$attributesGroups = $divaProduct->getAttributesGroups(1);
if (empty($attributesGroups)) {
$this_sku = array("id_product" => $id_product, "id_sku" => "ID-{$id_product}", "is_parent" => false, "attribute" => null);
array_push($skus, $this_sku);
} else {
$this_sku = array("id_product" => $id_product, "id_sku" => "ID-{$id_product}", "is_parent" => true, "attribute" => null);
array_push($skus, $this_sku);
foreach ($attributesGroups as $attribute) {
$size = $attribute['attribute_name'];
$id_sku = "ID-{$id_product}-{$size}";
$this_sku = array("id_product" => $id_product, "id_sku" => $id_sku, "is_parent" => false, "attribute" => $attribute);
array_push($skus, $this_sku);
}
}
unset($divaProduct);
}
return $skus;
}
示例7: buildTags
/**
* Builds the tag list for the product.
*
* Also includes the custom "add-to-cart" tag if the product can be added to the shopping cart directly without
* any action from the user, e.g. the product cannot have any variations or choices. This tag is then used in the
* recommendations to render the "Add to cart" button for the product when it is recommended to a user.
*
* @param Product $product the product model.
* @param int $id_lang for which language ID to fetch the product tags.
* @return array the built tags.
*/
protected function buildTags(Product $product, $id_lang)
{
$tags = array();
if (($product_tags = $product->getTags($id_lang)) !== '') {
$tags = explode(', ', $product_tags);
}
// If the product has no attributes (color, size etc.), then we mark it as possible to add directly to cart.
$product_attributes = $product->getAttributesGroups($id_lang);
if (empty($product_attributes)) {
$tags[] = self::ADD_TO_CART;
}
return $tags;
}
示例8: initFormPrices
/**
* @param Product $obj
* @throws Exception
* @throws SmartyException
*/
public function initFormPrices($obj)
{
$data = $this->createTemplate($this->tpl_form);
$product = $obj;
if ($obj->id) {
$shops = Shop::getShops();
$countries = Country::getCountries($this->context->language->id);
$groups = Group::getGroups($this->context->language->id);
$currencies = Currency::getCurrencies();
$attributes = $obj->getAttributesGroups((int) $this->context->language->id);
$combinations = array();
foreach ($attributes as $attribute) {
$combinations[$attribute['id_product_attribute']]['id_product_attribute'] = $attribute['id_product_attribute'];
if (!isset($combinations[$attribute['id_product_attribute']]['attributes'])) {
$combinations[$attribute['id_product_attribute']]['attributes'] = '';
}
$combinations[$attribute['id_product_attribute']]['attributes'] .= $attribute['attribute_name'] . ' - ';
$combinations[$attribute['id_product_attribute']]['price'] = Tools::displayPrice(Tools::convertPrice(Product::getPriceStatic((int) $obj->id, false, $attribute['id_product_attribute']), $this->context->currency), $this->context->currency);
}
foreach ($combinations as &$combination) {
$combination['attributes'] = rtrim($combination['attributes'], ' - ');
}
$data->assign('specificPriceModificationForm', $this->_displaySpecificPriceModificationForm($this->context->currency, $shops, $currencies, $countries, $groups));
$data->assign('ecotax_tax_excl', (int) $obj->ecotax);
$this->_applyTaxToEcotax($obj);
$data->assign(array('shops' => $shops, 'admin_one_shop' => count($this->context->employee->getAssociatedShops()) == 1, 'currencies' => $currencies, 'countries' => $countries, 'groups' => $groups, 'combinations' => $combinations, 'multi_shop' => Shop::isFeatureActive(), 'link' => new Link(), 'pack' => new Pack()));
} else {
$this->displayWarning($this->l('You must save this product before adding specific pricing'));
$product->id_tax_rules_group = (int) Product::getIdTaxRulesGroupMostUsed();
$data->assign('ecotax_tax_excl', 0);
}
$address = new Address();
$address->id_country = (int) $this->context->country->id;
$tax_rules_groups = TaxRulesGroup::getTaxRulesGroups(true);
$tax_rates = array(0 => array('id_tax_rules_group' => 0, 'rates' => array(0), 'computation_method' => 0));
foreach ($tax_rules_groups as $tax_rules_group) {
$id_tax_rules_group = (int) $tax_rules_group['id_tax_rules_group'];
$tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator();
$tax_rates[$id_tax_rules_group] = array('id_tax_rules_group' => $id_tax_rules_group, 'rates' => array(), 'computation_method' => (int) $tax_calculator->computation_method);
if (isset($tax_calculator->taxes) && count($tax_calculator->taxes)) {
foreach ($tax_calculator->taxes as $tax) {
$tax_rates[$id_tax_rules_group]['rates'][] = (double) $tax->rate;
}
} else {
$tax_rates[$id_tax_rules_group]['rates'][] = 0;
}
}
// prices part
$data->assign(array('link' => $this->context->link, 'currency' => $currency = $this->context->currency, 'tax_rules_groups' => $tax_rules_groups, 'taxesRatesByGroup' => $tax_rates, 'ecotaxTaxRate' => Tax::getProductEcotaxRate(), 'tax_exclude_taxe_option' => Tax::excludeTaxeOption(), 'ps_use_ecotax' => Configuration::get('PS_USE_ECOTAX')));
$product->price = Tools::convertPrice($product->price, $this->context->currency, true, $this->context);
if ($product->unit_price_ratio != 0) {
$data->assign('unit_price', Tools::ps_round($product->price / $product->unit_price_ratio, 6));
} else {
$data->assign('unit_price', 0);
}
$data->assign('ps_tax', Configuration::get('PS_TAX'));
$data->assign('country_display_tax_label', $this->context->country->display_tax_label);
$data->assign(array('currency', $this->context->currency, 'product' => $product, 'token' => $this->token));
$this->tpl_form_vars['custom_form'] = $data->fetch();
}
示例9: _hasVariationsMatching
private static function _hasVariationsMatching($product_id, $id_lang, $ebay_category, $ebay_site_id)
{
$product = new Product($product_id);
$attribute_groups = $product->getAttributesGroups($id_lang);
$attribute_group_ids = array_unique(array_map(array('EbaySynchronizer', 'getIdAttributeGroup'), $attribute_groups));
// test if has attribute that are not can_variation, in that case => no multisku
$nb_no_variation_attribute_groups = Db::getInstance()->getValue('SELECT COUNT(*)
FROM `' . _DB_PREFIX_ . 'ebay_category_specific`
WHERE `can_variation` = 0
AND `ebay_site_id` = ' . (int) $ebay_site_id . '
AND `id_attribute_group` IN (' . implode(', ', $attribute_group_ids) . ')');
if ($nb_no_variation_attribute_groups) {
return false;
}
// test if all the attribute_groups without matching are not conflicting with an item_specific name
$category_specifics = Db::getInstance()->executeS('SELECT `id_attribute_group`
FROM `' . _DB_PREFIX_ . 'ebay_category_specific`
WHERE `id_attribute_group` IN (' . implode(', ', $attribute_group_ids) . ')
AND `ebay_site_id` = ' . (int) $ebay_site_id);
$with_settings_attribute_group_ids = array_map(array('EbaySynchronizer', 'getIdAttributeGroup'), $category_specifics);
$without_settings_attribute_group_ids = array_diff($attribute_group_ids, $with_settings_attribute_group_ids);
foreach ($attribute_groups as $attribute_group) {
if (!in_array($attribute_group['id_attribute_group'], $without_settings_attribute_group_ids)) {
continue;
}
// Check if items specifics no variation has the same name as the attribute => multi product
foreach ($ebay_category->getItemsSpecificValues() as $item_specific) {
if ($item_specific['name'] === $attribute_group['group_name'] && $item_specific['can_variation'] == 0) {
return false;
}
}
}
return true;
}
示例10: header
header('Content-Disposition: attachment; filename="products-qty.csv"');
$outstream = fopen("php://output", 'w');
$record = array("ID", "Size", "Code", "Qty");
fputcsv($outstream, $record, ',', '"');
$target_path = "import/";
$target_path = $target_path . basename($_FILES['product_ids']['name']) . time();
if (move_uploaded_file($_FILES['product_ids']['tmp_name'], $target_path)) {
$f = fopen($target_path, 'r');
if ($f) {
$db = Db::getInstance(_PS_USE_SQL_SLAVE_);
$count = 0;
fgetcsv($f);
while ($line = fgetcsv($f)) {
$id_product = intval($line[0]);
$product = new Product($id_product, true, 1);
$attributesGroups = $product->getAttributesGroups(1);
$quantity = 0;
if (!empty($attributesGroups)) {
foreach ($attributesGroups as $group) {
$record = array($id_product, $group['attribute_name'], $product->reference, $group['quantity']);
fputcsv($outstream, $record, ',', '"');
$quantity += intval($group['quantity']);
}
}
if (empty($attributesGroups)) {
$quantity = $product->quantity;
}
$record = array($id_product, "", $product->reference, $quantity);
fputcsv($outstream, $record, ',', '"');
}
}
示例11: process
public function process()
{
parent::process();
if (!($id_category = (int) Tools::getValue('id_category')) or !Validate::isUnsignedId($id_category)) {
$this->errors[] = Tools::displayError('Missing category ID');
} else {
if (!Validate::isLoadedObject($this->category)) {
$this->errors[] = Tools::displayError('Category does not exist');
} elseif (!$this->category->checkAccess((int) self::$cookie->id_customer)) {
$this->errors[] = Tools::displayError('You do not have access to this category.');
} elseif (!$this->category->active) {
self::$smarty->assign('category', $this->category);
} else {
$rewrited_url = self::$link->getCategoryLink((int) $this->category->id, $this->category->link_rewrite);
/* Scenes (could be externalised to another controler if you need them */
self::$smarty->assign('scenes', Scene::getScenes((int) $this->category->id, (int) self::$cookie->id_lang, true, false));
/* Scenes images formats */
if ($sceneImageTypes = ImageType::getImagesTypes('scenes')) {
foreach ($sceneImageTypes as $sceneImageType) {
if ($sceneImageType['name'] == 'thumb_scene') {
$thumbSceneImageType = $sceneImageType;
} elseif ($sceneImageType['name'] == 'large_scene') {
$largeSceneImageType = $sceneImageType;
}
}
self::$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL);
self::$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL);
}
$this->category->description = nl2br2($this->category->description);
$subCategories = $this->category->getSubCategories((int) self::$cookie->id_lang);
self::$smarty->assign('category', $this->category);
if (Db::getInstance()->numRows()) {
self::$smarty->assign('subcategories', $subCategories);
self::$smarty->assign(array('subcategories_nb_total' => sizeof($subCategories), 'subcategories_nb_half' => ceil(sizeof($subCategories) / 2)));
}
if ($this->category->id != 1) {
$nbProducts = $this->category->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
$this->pagination((int) $nbProducts);
self::$smarty->assign('nb_products', (int) $nbProducts);
$cat_products = $this->category->getProducts((int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay);
if ($cat_products) {
foreach ($cat_products as $cat_product) {
$prod_features[$cat_product["id_product"]] = Product::getFrontFeaturesStatic(self::$cookie->id_lang, $cat_product['id_product']);
$aux_product = new Product($cat_product["id_product"], true, self::$cookie->id_lang);
$aux_attributesGroups = $aux_product->getAttributesGroups((int) self::$cookie->id_lang);
foreach ($aux_attributesGroups as $k => $row) {
$aux_combinations[$row['attribute_name']]['price'] = (double) $row['price'];
}
$prod_combinations[$cat_product["id_product"]] = $aux_combinations;
unset($aux_combinations);
}
}
}
if (isset($prod_features)) {
self::$smarty->assign('prod_features', $prod_features);
}
if (isset($prod_combinations)) {
self::$smarty->assign('prod_combinations', $prod_combinations);
}
self::$smarty->assign(array('products' => (isset($cat_products) and $cat_products) ? $cat_products : NULL, 'id_category' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath((int) $this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize('category'), 'mediumSize' => Image::getSize('medium'), 'thumbSceneSize' => Image::getSize('thumb_scene'), 'homeSize' => Image::getSize('home')));
foreach ($subCategories as $subCat) {
$secondLevelCats[$subCat["id_category"]] = $this->getSubCats($subCat["id_category"]);
}
if (isset($secondLevelCats)) {
self::$smarty->assign('secondLevelCats', $secondLevelCats);
}
}
}
self::$smarty->assign(array('allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers()));
}
示例12: getSKUs
protected function getSKUs($products)
{
$skus = array();
foreach ($products as $product) {
$id_product = $product['id_product'];
// $id_product ='58709';
// if($id_product >72390 && $id_product <72400)
// continue;
$this->echomsg("Preparing SKUs for {$id_product}");
$divaProduct = new Product($id_product, true, 1);
$found_skus = array();
$attributesGroups = $divaProduct->getAttributesGroups(1);
if (empty($attributesGroups)) {
$this_sku = array("id_product" => $id_product, "id_sku" => "ID-{$id_product}", "is_parent" => false, "attribute" => null);
array_push($found_skus, $this_sku['id_sku']);
array_push($skus, $this_sku);
} else {
$this_sku = array("id_product" => $id_product, "id_sku" => "ID-{$id_product}", "is_parent" => true, "attribute" => null);
array_push($found_skus, $this_sku['id_sku']);
array_push($skus, $this_sku);
foreach ($attributesGroups as $attribute) {
$size = $attribute['attribute_name'];
$id_sku = "ID-{$id_product}-{$size}";
$this_sku = array("id_product" => $id_product, "id_sku" => $id_sku, "is_parent" => false, "attribute" => $attribute);
array_push($found_skus, $this_sku['id_sku']);
array_push($skus, $this_sku);
}
}
//check if there are other SKUs for this product already on amazon but deleted in our system
$csql = "select id_sku from ps_affiliate_feed_product_info where id_product = {$id_product} and concat('ID-',id_product) != id_sku";
$cres = $this->db->ExecuteS($csql);
if (!empty($cres) && count($cres) > 0) {
foreach ($cres as $c) {
if (in_array($c['id_sku'], $found_skus)) {
continue;
}
$this_sku = array("id_product" => $id_product, "id_sku" => $c['id_sku'], "is_parent" => false, "attribute" => null, "inactive" => true);
array_push($skus, $this_sku);
}
}
unset($divaProduct);
}
return $skus;
}
示例13: getProductAttributeCombinations
public function getProductAttributeCombinations($id_product)
{
$combinations = array();
$context = Context::getContext();
$product = new Product($id_product, $context->language->id);
$attributes_groups = $product->getAttributesGroups($context->language->id);
$combination_prices_set = array();
foreach ($attributes_groups as $k => $row) {
$combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name'];
$combinations[$row['id_product_attribute']]['attributes_group'][$row['id_attribute_group']] = $row['group_name'];
$combinations[$row['id_product_attribute']]['attributes_groups'] = @implode(', ', $combinations[$row['id_product_attribute']]['attributes_group']);
$combinations[$row['id_product_attribute']]['attributes_names'] = @implode(', ', $combinations[$row['id_product_attribute']]['attributes_values']);
$combinations[$row['id_product_attribute']]['attributes'][] = (int) $row['id_attribute'];
$combinations[$row['id_product_attribute']]['price'] = (double) $row['price'];
if (!isset($combination_prices_set[(int) $row['id_product_attribute']])) {
Product::getPriceStatic((int) $this->id, false, $row['id_product_attribute'], 6, null, false, true, 1, false, null, null, null, $combination_specific_price);
$combination_prices_set[(int) $row['id_product_attribute']] = true;
$combinations[$row['id_product_attribute']]['specific_price'] = $combination_specific_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'];
if ($row['available_date'] != '0000-00-00') {
$combinations[$row['id_product_attribute']]['available_date'] = $row['available_date'];
$combinations[$row['id_product_attribute']]['date_formatted'] = Tools::displayDate($row['available_date']);
} else {
$combinations[$row['id_product_attribute']]['available_date'] = '';
}
foreach ($combinations as $id_product_attribute => $comb) {
$attribute_list = '';
foreach ($comb['attributes'] as $id_attribute) {
$attribute_list .= '\'' . (int) $id_attribute . '\',';
}
$attribute_list = rtrim($attribute_list, ',');
$combinations[$id_product_attribute]['list'] = $attribute_list;
}
}
return $combinations;
}