本文整理汇总了PHP中Attribute::getHigherPosition方法的典型用法代码示例。如果您正苦于以下问题:PHP Attribute::getHigherPosition方法的具体用法?PHP Attribute::getHigherPosition怎么用?PHP Attribute::getHigherPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attribute
的用法示例。
在下文中一共展示了Attribute::getHigherPosition方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_singleDimension
function save_singleDimension($v0390f4ac89dd, $v7dbfca66c609, $vb8f02101126e)
{
global $cookie;
$v9661b333c109 = (int) Db::getInstance()->getValue('SELECT id_product_attribute FROM ' . _DB_PREFIX_ . 'product_attribute WHERE id_product = ' . $v0390f4ac89dd . ' AND default_on = 1 ORDER BY id_product_attribute DESC');
$v0d483f03670f = Db::getInstance()->ExecuteS('SELECT id_attribute FROM ' . _DB_PREFIX_ . 'product_attribute_combination WHERE id_product_attribute = ' . $v9661b333c109);
$v2dcd27727003 = Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'product_attribute WHERE default_on = 1 AND id_product = ' . $v0390f4ac89dd);
Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'product_attribute SET default_on = 0 WHERE id_product = ' . $v0390f4ac89dd);
if (!($vd91705970ca1 = (int) Db::getInstance()->getValue('SELECT a.id_attribute FROM ' . _DB_PREFIX_ . 'attribute AS a LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang AS al ON a.id_attribute = al.id_attribute WHERE a.id_attribute_group = ' . $v7dbfca66c609 . ' AND al.id_lang = ' . (int) $cookie->id_lang . ' AND al.name = "' . $vb8f02101126e . '"'))) {
if ((double) substr(_PS_VERSION_, 0, 3) >= 1.5) {
$v152cf454beb9 = (int) Attribute::getHigherPosition($v7dbfca66c609);
$v152cf454beb9++;
$vef258eea13a5 = 'INSERT INTO ' . _DB_PREFIX_ . 'attribute (id_attribute_group, position) VALUES (' . $v7dbfca66c609 . ', ' . $v152cf454beb9 . ')';
} else {
$vef258eea13a5 = 'INSERT INTO ' . _DB_PREFIX_ . 'attribute (id_attribute_group) VALUES (' . $v7dbfca66c609 . ')';
}
Db::getInstance()->execute($vef258eea13a5);
$vd91705970ca1 = Db::getInstance()->Insert_ID();
if ((double) substr(_PS_VERSION_, 0, 3) >= 1.5) {
$v59cefedeccb8 = (int) $v1869f6698708->id_shop;
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'attribute_shop (id_attribute, id_shop) VALUES (' . $vd91705970ca1 . ', ' . $v59cefedeccb8 . ')');
}
for ($vf7a487fdfbf4 = 1; $vf7a487fdfbf4 < 6; $vf7a487fdfbf4++) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'attribute_lang (`id_attribute`, `id_lang`, `name`) VALUES (' . $vd91705970ca1 . ', ' . $vf7a487fdfbf4 . ', ' . $vb8f02101126e . ')');
}
}
$v489fcc49bdb7 = '';
$v65a9a2b21a04 = '';
if ((double) substr(_PS_VERSION_, 0, 3) >= 1.5) {
$v489fcc49bdb7 = ', available_date';
$v65a9a2b21a04 = ', "0000-00-00"';
}
if (Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'product_attribute (id_product, quantity, price, aimd_value, weight, default_on' . $v489fcc49bdb7 . ') VALUES (' . $v2dcd27727003['id_product'] . ', 1, ' . $v2dcd27727003['price'] . ', 0, ' . $v2dcd27727003['weight'] . ', 1' . $v65a9a2b21a04 . ')')) {
$vb5c94481c96a = Db::getInstance()->Insert_ID();
Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'product SET quantity = quantity + 1 WHERE id_product = ' . $v0390f4ac89dd);
foreach ($v0d483f03670f as $v1e7b1f8152e0) {
$v31b067b2f701 = (int) $v1e7b1f8152e0['id_attribute'];
if ($v7dbfca66c609 == (int) Db::getInstance()->getValue('SELECT id_attribute_group FROM ' . _DB_PREFIX_ . 'attribute WHERE id_attribute = ' . $v31b067b2f701)) {
$v31b067b2f701 = $vd91705970ca1;
}
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'product_attribute_combination (id_attribute, id_product_attribute) VALUES (' . $v31b067b2f701 . ', ' . $vb5c94481c96a . ')');
}
$v643e6a337530 = Db::getInstance()->getValue('SELECT id_image FROM ' . _DB_PREFIX_ . 'product_attribute_image WHERE id_product_attribute = ' . $v2dcd27727003['id_product_attribute']);
if ($v643e6a337530) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'product_attribute_image (id_product_attribute, id_image) VALUES (' . $vb5c94481c96a . ', ' . $v643e6a337530 . ')');
}
if ((double) substr(_PS_VERSION_, 0, 3) >= 1.5) {
Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'product_attribute_shop SET default_on = 0 WHERE id_product_attribute IN (SELECT id_product_attribute FROM ' . _DB_PREFIX_ . 'product_attribute WHERE ' . 'id_product = ' . $v0390f4ac89dd . ')');
if ((int) Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') == 1 && (Tools::getIsset('shop_linked') && Tools::getValue('shop_linked'))) {
$v003fcea77e06 = array((int) Tools::getValue('shop_linked'));
} else {
$v003fcea77e06 = Db::getInstance()->ExecuteS('SELECT id_shop FROM ' . _DB_PREFIX_ . 'shop WHERE active = 1');
}
foreach ($v003fcea77e06 as $v59cefedeccb8) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'product_attribute_shop (id_product_attribute, id_shop, price, wholesale_price, weight, minimal_quantity, default_on, available_date) VALUES (' . $vb5c94481c96a . ', ' . (int) $v59cefedeccb8['id_shop'] . ', ' . $v2dcd27727003['price'] . ', ' . $v2dcd27727003['wholesale_price'] . ', ' . $v2dcd27727003['weight'] . ', ' . $v2dcd27727003['minimal_quantity'] . ', 1, "0000-00-00")');
}
}
}
}
示例2: add
public function add($autodate = true, $null_values = false)
{
if ($this->position <= 0) {
$this->position = Attribute::getHigherPosition($this->id_attribute_group) + 1;
}
$return = parent::add($autodate, $null_values);
if ($return) {
Hook::exec('actionAttributeSave', array('id_attribute' => $this->id));
}
return $return;
}
示例3: attributeImportOne
//.........这里部分代码省略.........
}
}
}
}
$id_attribute_group = 0;
// groups
$groups_attributes = array();
if (isset($info['group'])) {
foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group) {
if (empty($group)) {
continue;
}
$tab_group = explode(':', $group);
$group = trim($tab_group[0]);
if (!isset($tab_group[1])) {
$type = 'select';
} else {
$type = trim($tab_group[1]);
}
// sets group
$groups_attributes[$key]['group'] = $group;
// if position is filled
if (isset($tab_group[2])) {
$position = trim($tab_group[2]);
} else {
$position = false;
}
if (!isset($groups[$group])) {
$obj = new AttributeGroup();
$obj->is_color_group = false;
$obj->group_type = pSQL($type);
$obj->name[$default_language] = $group;
$obj->public_name[$default_language] = $group;
$obj->position = !$position ? AttributeGroup::getHigherPosition() + 1 : $position;
if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
// here, cannot avoid attributeGroup insertion to avoid an error during validation step.
//if (!$validateOnly) {
$obj->add();
$obj->associateTo($id_shop_list);
$groups[$group] = $obj->id;
//}
} else {
$this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '');
}
// fills groups attributes
$id_attribute_group = $obj->id;
$groups_attributes[$key]['id'] = $id_attribute_group;
} else {
// already exists
$id_attribute_group = $groups[$group];
$groups_attributes[$key]['id'] = $id_attribute_group;
}
}
}
// inits attribute
$id_product_attribute = 0;
$id_product_attribute_update = false;
$attributes_to_add = array();
// for each attribute
if (isset($info['attribute'])) {
foreach (explode($this->multiple_value_separator, $info['attribute']) as $key => $attribute) {
if (empty($attribute)) {
continue;
}
$tab_attribute = explode(':', $attribute);
$attribute = trim($tab_attribute[0]);
示例4: floatval
} else {
$group_reduction -= floatval($groupReduction);
}
}
$more_attributes_price *= $group_reduction;
// If other return only the attributes price
if ($request_others && ($request_attr_2 == '' && $request_attr_3 == '-1' || $request_attr_2 != '' && $request_attr_3 == '' || $request_value == '')) {
die('Price->' . $more_attributes_price);
}
$group = str_replace('group_', '', $request_group);
$result = DB::getInstance()->ExecuteS('SELECT attribute.id_attribute FROM ' . _DB_PREFIX_ . 'attribute AS attribute, ' . _DB_PREFIX_ . 'attribute_lang AS lang WHERE attribute.id_attribute_group = ' . $group . ' AND lang.name = "' . $param1 . '" AND lang.id_lang = ' . (int) $cookie->id_lang . ' AND attribute.id_attribute = lang.id_attribute');
// Value creation if needed
if (!isset($result[0])) {
// Attribut creation if needed
if ((double) substr(_PS_VERSION_, 0, 3) >= 1.5) {
$position = (int) Attribute::getHigherPosition($group);
$position++;
$request = 'INSERT INTO ' . _DB_PREFIX_ . 'attribute (id_attribute_group, position) VALUES (' . $group . ', ' . $position . ')';
} else {
$request = 'INSERT INTO ' . _DB_PREFIX_ . 'attribute (id_attribute_group) VALUES (' . $group . ')';
}
if (Db::getInstance()->Execute($request)) {
$attribute_id = Db::getInstance()->Insert_ID();
// Add for Prestashop 1.5 version and above
if ((double) substr(_PS_VERSION_, 0, 3) >= 1.5) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'attribute_shop (id_attribute, id_shop) VALUES (' . $attribute_id . ', ' . $shop_id . ')');
}
// Attribute lang creation if needed
for ($cpt = 1; $cpt < 6; $cpt++) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'attribute_lang (`id_attribute`, `id_lang`, `name`) VALUES (' . $attribute_id . ', ' . $cpt . ', ' . $param1 . ')');
}
示例5: attributeImport
//.........这里部分代码省略.........
}
}
}
if (!$id_image) {
$this->warnings[] = sprintf(Tools::displayError('No image was found for combination with id_product = %s and image position = %s.'), $product->id, (int) $info['image_position']);
}
}
$id_attribute_group = 0;
// groups
$groups_attributes = array();
if (isset($info['group'])) {
foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group) {
$tab_group = explode(':', $group);
$group = trim($tab_group[0]);
if (!isset($tab_group[1])) {
$type = 'select';
} else {
$type = trim($tab_group[1]);
}
// sets group
$groups_attributes[$key]['group'] = $group;
// if position is filled
if (isset($tab_group[2])) {
$position = trim($tab_group[2]);
} else {
$position = false;
}
if (!isset($groups[$group])) {
$obj = new AttributeGroup();
$obj->is_color_group = false;
$obj->group_type = pSQL($type);
$obj->name[$default_language] = $group;
$obj->public_name[$default_language] = $group;
$obj->position = !$position ? AttributeGroup::getHigherPosition() + 1 : $position;
if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
$obj->add();
$obj->associateTo($id_shop_list);
$groups[$group] = $obj->id;
} else {
$this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '');
}
// fils groups attributes
$id_attribute_group = $obj->id;
$groups_attributes[$key]['id'] = $id_attribute_group;
} else {
$id_attribute_group = $groups[$group];
$groups_attributes[$key]['id'] = $id_attribute_group;
}
}
}
// inits attribute
$id_product_attribute = 0;
$id_product_attribute_update = false;
$attributes_to_add = array();
// for each attribute
if (isset($info['attribute'])) {
foreach (explode($this->multiple_value_separator, $info['attribute']) as $key => $attribute) {
$tab_attribute = explode(':', $attribute);
$attribute = trim($tab_attribute[0]);
// if position is filled
if (isset($tab_attribute[1])) {
$position = trim($tab_attribute[1]);
} else {
$position = false;
}
if (isset($groups_attributes[$key])) {
示例6: _link_product
/**
* \brief Link a product to an attribute
* \param integer Product id
* \param array Attributes id to link
* \param integer Attributes group id
* \param string Value of the scale in config parameters
* \param string Fixed dimensions separated by a comma
* \param boolean Indicates if there are fixed values to update
* \param boolean Indicates if it's a product update
* \param integer Default value to display
* \param array Default values
* \retval boolean Result of the operation
*/
private function _link_product($product_id, $attributes_id, $group_id, $scale, $fixed_dimensions, &$fixed_update, $update, $default, &$default_values)
{
global $cookie;
$return = true;
// Get the scale default value
$scale_value = $this->_get_scale($scale);
// Get the default attribute
$attribute = Db::getInstance()->getRow('SELECT attribute.* FROM ' . _DB_PREFIX_ . 'attribute as attribute LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang as lang ON ' . 'lang.id_attribute = attribute.id_attribute WHERE attribute.id_attribute_group = ' . $group_id . ' AND lang.name = "' . $scale_value . '" AND lang.id_lang = ' . (int) $cookie->id_lang);
// Create dimensions only if not an update
if (!$update) {
// We add each attribute
foreach ($attributes_id as $attribute_id) {
if (!Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'product_attribute_combination (id_attribute, id_product_attribute) VALUES (' . $attribute['id_attribute'] . ', ' . $attribute_id['id_product_attribute'] . ')')) {
$return = false;
break;
}
}
}
// Set attribute impact for delayed combinations module
$impact = (int) Db::getInstance()->getValue('SELECT id_attribute_impact FROM ' . _DB_PREFIX_ . 'attribute_impact WHERE id_product = ' . $product_id . ' AND id_attribute = ' . $attribute['id_attribute']);
if (!$impact) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'attribute_impact (id_product, id_attribute, weight, price) VALUES (' . $product_id . ', ' . $attribute['id_attribute'] . ', 0, 0)');
}
// Insert in shops if needed
$shops_id = array();
if ((double) substr(_PS_VERSION_, 0, 3) >= 1.5) {
if ((int) Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') == 1 && (Tools::getIsset('shop_linked') && Tools::getValue('shop_linked'))) {
$shops_id = array((int) Tools::getValue('shop_linked'));
} else {
$shops_id = Db::getInstance()->ExecuteS('SELECT id_shop FROM ' . _DB_PREFIX_ . 'shop WHERE active = 1');
}
}
// Save fixed dimension if needed
if ($return && $fixed_dimensions) {
// If update, delete fixed dimensions in DB before to add them
if ($update) {
Db::getInstance()->Execute('DELETE FROM ' . _DB_PREFIX_ . 'aimultidimensions_fixed_dimensions WHERE fd_product = ' . $product_id . ' AND fd_attribute_group = ' . $attribute['id_attribute_group']);
}
$fixed_dimensions = str_replace(', ', ',', $fixed_dimensions);
$fixed = explode(',', $fixed_dimensions);
foreach ($fixed as $value) {
if (Validate::isFloat($value)) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'aimultidimensions_fixed_dimensions (fd_product, fd_attribute_group, fd_value) VALUES (' . $product_id . ', ' . $attribute['id_attribute_group'] . ', ' . $value . ')');
}
// Attribut creation if needed
$attribute_id = (int) Db::getInstance()->getValue('SELECT a.id_attribute FROM ' . _DB_PREFIX_ . 'attribute AS a LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang AS al ON al.id_attribute = a.id_attribute WHERE ' . 'a.id_attribute_group = ' . $attribute['id_attribute_group'] . ' AND al.name = ' . $value . ' GROUP BY a.id_attribute ORDER BY a.id_attribute DESC');
if (!$attribute_id) {
// Attribut creation if needed
if ((double) substr(_PS_VERSION_, 0, 3) >= 1.5) {
$position = (int) Attribute::getHigherPosition($group_id);
$position++;
$request = 'INSERT INTO ' . _DB_PREFIX_ . 'attribute (id_attribute_group, position) VALUES (' . $group_id . ', ' . $position . ')';
} else {
$request = 'INSERT INTO ' . _DB_PREFIX_ . 'attribute (id_attribute_group) VALUES (' . $group_id . ')';
}
if (Db::getInstance()->Execute($request)) {
$attribute_id = Db::getInstance()->Insert_ID();
// Attribute lang creation if needed
for ($cpt = 1; $cpt < 6; $cpt++) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'attribute_lang (`id_attribute`, `id_lang`, `name`) VALUES (' . $attribute_id . ', ' . $cpt . ', ' . $value . ')');
}
// Add for Prestashop 1.5 version and above
if ((double) substr(_PS_VERSION_, 0, 3) >= 1.5) {
foreach ($shops_id as $shop_id) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'attribute_shop (id_attribute, id_shop) VALUES (' . $attribute_id . ', ' . (int) $shop_id['id_shop'] . ')');
}
}
}
}
}
}
// Save default dimensions
$default_dimension = Db::getInstance()->getRow('SELECT al.name, al.id_attribute FROM ' . _DB_PREFIX_ . 'attribute_lang AS al LEFT JOIN ' . _DB_PREFIX_ . 'attribute AS a ON a.id_attribute = al.id_attribute WHERE ' . 'a.id_attribute_group = ' . $group_id . ' AND al.id_lang = ' . (int) $cookie->id_lang . ' ORDER BY a.id_attribute ASC');
if ($default != (int) $default_dimension['name']) {
// Attribut creation if needed
$attribute_id = (int) Db::getInstance()->getValue('SELECT a.id_attribute FROM ' . _DB_PREFIX_ . 'attribute AS a LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang AS al ON al.id_attribute = a.id_attribute WHERE ' . 'a.id_attribute_group = ' . $group_id . ' AND al.name = ' . $default . ' GROUP BY a.id_attribute ORDER BY a.id_attribute DESC');
if (!$attribute_id) {
if ((double) substr(_PS_VERSION_, 0, 3) >= 1.5) {
$position = (int) Attribute::getHigherPosition($group_id);
$position++;
$request = 'INSERT INTO ' . _DB_PREFIX_ . 'attribute (id_attribute_group, position) VALUES (' . $group_id . ', ' . $position . ')';
} else {
$request = 'INSERT INTO ' . _DB_PREFIX_ . 'attribute (id_attribute_group) VALUES (' . $group_id . ')';
}
if (Db::getInstance()->Execute($request)) {
$attribute_id = Db::getInstance()->Insert_ID();
// Attribute lang creation if needed
//.........这里部分代码省略.........
示例7: array
<?php
$group = 'Format eBook';
$default_language = Configuration::get('PS_LANG_DEFAULT');
$id_shop_list = array(1);
$position = AttributeGroup::getHigherPosition() + 1;
$attributeGroup = new AttributeGroup();
$attributeGroup->is_color_group = false;
$attributeGroup->group_type = pSQL('select');
$attributeGroup->name[$default_language] = $group;
$attributeGroup->public_name[$default_language] = $group;
$attributeGroup->position = $position;
$attributeGroup->add();
$attributeGroup->associateTo($id_shop_list);
// create one attribute for each file type
foreach ($this->file_types as $type) {
$position_attribute = Attribute::getHigherPosition($attributeGroup->id) + 1;
$obj = new Attribute();
$obj->id_attribute_group = $attributeGroup->id;
$obj->name[$default_language] = $type;
$obj->position = $position_attribute;
$obj->add();
$obj->associateTo($id_shop_list);
Configuration::updateValue('prestaebooks_attribute_id_' . $type, $obj->id);
}
示例8: attributeImport
//.........这里部分代码省略.........
}
if (empty($id_image)) {
$this->warnings[] = sprintf(Tools::displayError('No image was found for combination with id_product = %s and image position = %s.'), $product->id, (int) $position);
}
}
}
}
$id_attribute_group = 0;
$groups_attributes = array();
if (isset($info['group'])) {
foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group) {
if (empty($group)) {
continue;
}
$tab_group = explode(':', $group);
$group = trim($tab_group[0]);
if (!isset($tab_group[1])) {
$type = 'select';
} else {
$type = trim($tab_group[1]);
}
$groups_attributes[$key]['group'] = $group;
if (isset($tab_group[2])) {
$position = trim($tab_group[2]);
} else {
$position = false;
}
if (!isset($groups[$group])) {
$obj = new AttributeGroup();
$obj->is_color_group = false;
$obj->group_type = pSQL($type);
$obj->name[$default_language] = $group;
$obj->public_name[$default_language] = $group;
$obj->position = !$position ? AttributeGroup::getHigherPosition() + 1 : $position;
if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
$obj->add();
$obj->associateTo($id_shop_list);
$groups[$group] = $obj->id;
} else {
$this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '');
}
$id_attribute_group = $obj->id;
$groups_attributes[$key]['id'] = $id_attribute_group;
} else {
$id_attribute_group = $groups[$group];
$groups_attributes[$key]['id'] = $id_attribute_group;
}
}
}
$id_product_attribute = 0;
$id_product_attribute_update = false;
$attributes_to_add = array();
if (isset($info['attribute'])) {
foreach (explode($this->multiple_value_separator, $info['attribute']) as $key => $attribute) {
if (empty($attribute)) {
continue;
}
$tab_attribute = explode(':', $attribute);
$attribute = trim($tab_attribute[0]);
if (isset($tab_attribute[1])) {
$position = trim($tab_attribute[1]);
} else {
$position = false;
}
if (isset($groups_attributes[$key])) {
$group = $groups_attributes[$key]['group'];