本文整理汇总了PHP中AttributeGroup类的典型用法代码示例。如果您正苦于以下问题:PHP AttributeGroup类的具体用法?PHP AttributeGroup怎么用?PHP AttributeGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AttributeGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContent
function getContent()
{
$is_one_dot_five = version_compare(_PS_VERSION_, '1.5', '>');
// Smarty
$template_vars = array('id_tab' => Tools::getValue('id_tab'), 'controller' => Tools::getValue('controller'), 'tab' => Tools::getValue('tab'), 'configure' => Tools::getValue('configure'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'), 'token' => Tools::getValue('token'), 'ebay_token' => Configuration::get('EBAY_SECURITY_TOKEN'), '_module_dir_' => _MODULE_DIR_, 'ebay_categories' => EbayCategoryConfiguration::getEbayCategories($this->ebay_profile->id), 'id_lang' => $this->context->cookie->id_lang, 'id_ebay_profile' => $this->ebay_profile->id, '_path' => $this->path, 'possible_attributes' => AttributeGroup::getAttributesGroups($this->context->cookie->id_lang), 'possible_features' => Feature::getFeatures($this->context->cookie->id_lang, true), 'date' => pSQL(date('Ymdhis')), 'conditions' => $this->_translatePSConditions(EbayCategoryConditionConfiguration::getPSConditions()), 'form_items_specifics' => EbaySynchronizer::getNbSynchronizableEbayCategoryCondition(), 'form_items_specifics_mixed' => EbaySynchronizer::getNbSynchronizableEbayCategoryConditionMixed(), 'isOneDotFive' => $is_one_dot_five);
return $this->display('formItemsSpecifics.tpl', $template_vars);
}
示例2: __construct
public function __construct($moduleInstance)
{
parent::__construct($moduleInstance);
$productIdOptions = array(array('value' => 0, 'name' => 'Reference Code'), array('value' => 1, 'name' => 'EAN-13 or JAN barcode'), array('value' => 2, 'name' => 'UPC barcode'));
$this->addSelectField('Product ID', 'map_id', $productIdOptions, true, $this->l('Select the product reference group you are using in your store'));
$productManufacturerOptions = array(array('value' => 0, 'name' => 'Product Manufacturer'), array('value' => 1, 'name' => 'Product Supplier'));
$this->addSelectField('Product Manufacturer', 'map_manufacturer', $productManufacturerOptions, true, $this->l('Select the field you are using to specify the manufacturer'));
$productLinkOptions = array(array('value' => 0, 'name' => 'Use Product Link'));
$this->addSelectField('Product Link', 'map_link', $productLinkOptions, true, $this->l('URL that leads to product. For upcoming features'));
$productImageLinkOptions = array(array('value' => 0, 'name' => 'Cover Image'), array('value' => 1, 'name' => 'Random Image'));
$this->addSelectField('Product Image', 'map_image', $productImageLinkOptions, true, $this->l('Choose if you want to use cover image or some random image from product\'s gallery'));
$productCategoriesOptions = array(array('value' => 0, 'name' => 'Categories'), array('value' => 1, 'name' => 'Tags'));
$this->addSelectField('Product Categories', 'map_category', $productCategoriesOptions, true, $this->l('Choose product tags if and only if no categories are set and instead product tags are in use'));
$productPriceOptions = array(array('value' => 0, 'name' => 'Retail price with tax'), array('value' => 1, 'name' => 'Pre-tax retail price'), array('value' => 2, 'name' => 'Pre-tax wholesale price'));
$this->addSelectField('Product Prices', 'map_price_with_vat', $productPriceOptions, true, $this->l('s option specify the product price that will be used in XML. This should be left to "Retail price with tax"'));
$productMPNOptions = array(array('value' => 0, 'name' => 'Reference Code'), array('value' => 1, 'name' => 'EAN-13 or JAN barcode'), array('value' => 2, 'name' => 'UPC barcode'), array('value' => 3, 'name' => 'Supplier Reference'));
$this->addSelectField('Product Manufacturer Reference Code', 'map_mpn', $productMPNOptions, true, $this->l('This option should reflect product\' manufacturer SKU'));
$productISBNOptions = array(array('value' => 0, 'name' => 'Reference Code'), array('value' => 1, 'name' => 'EAN-13 or JAN barcode'), array('value' => 2, 'name' => 'UPC barcode'), array('value' => 3, 'name' => 'Supplier Reference'));
$this->addSelectField('Product ISBN', 'map_isbn', $productISBNOptions, true, $this->l('This field will be used if you sell books in your store, to specify the ISBN of the book'));
// Multiselect from attribute groups
$default_lang = (int) \Configuration::get('PS_LANG_DEFAULT');
$productSizesOptions = array();
$productColorOptions = array();
$attributes = \AttributeGroup::getAttributesGroups($default_lang);
foreach ($attributes as $attribute) {
if ($attribute['is_color_group']) {
$productColorOptions[] = array('value' => $attribute['id_attribute_group'], 'name' => $attribute['name']);
} else {
$productSizesOptions[] = array('value' => $attribute['id_attribute_group'], 'name' => $attribute['name']);
}
}
$this->addMultiSelectField('Size Attributes', 'map_size', $productSizesOptions, true, $this->l('Choose the attributes that you use to specify product sizes. This field is used only if Fashion Store option is enabled'))->addMultiSelectField('Color Attributes', 'map_color', $productColorOptions, true, $this->l('Choose the attributes that you use to specify product colors. This field is used only if Fashion Store option is enabled'));
}
示例3: actionDelete
public function actionDelete($ids)
{
$ids = explode(',', $ids);
if (count($ids) > 0) {
foreach ($ids as $id) {
$attributeGroup = AttributeGroup::model()->findByPk($id);
$attributeGroup->delete();
}
}
$this->redirect(array('index'));
}
示例4: save
public function save()
{
$attributeGroup = AttributeGroup::model()->findByPk($this->id);
if (is_null($attributeGroup)) {
// is insert
$attributeGroup = new AttributeGroup();
$attributeGroup->sort_order = $this->sortOrder;
$attributeGroup->save();
$attributeDescription = new AttributeGroupDescription();
$attributeDescription->attribute_group_id = $attributeGroup->attribute_group_id;
$attributeDescription->language_id = 1;
// TODO: read locale
$attributeDescription->name = $this->name;
$attributeDescription->save();
} else {
$attributeGroup->sort_order = $this->sortOrder;
$attributeGroup->save();
$attributeGroup->description->name = $this->name;
$attributeGroup->description->save();
}
}
示例5: actionSort
public function actionSort()
{
if (isset($_POST['items']) && is_array($_POST['items'])) {
$i = 0;
foreach ($_POST['items'] as $item) {
$project = AttributeGroup::model()->findByPk($item);
$project->sort_order = $i;
$project->save();
$i++;
}
}
}
示例6: __construct
public function __construct()
{
$this->name = 'topshop';
$this->tab = 'smart_shopping';
$this->version = '1.7.7';
$this->author = 'Roman Prokofyev';
$this->need_instance = 1;
$this->display = 'view';
$this->bootstrap = true;
//$this->ps_versions_compliancy = array('min' => '1.5.0.0', 'max' => '1.6');
$this->module_key = '2149d8638f786d69c1a762f1fbfb8124';
$this->custom_attributes = array('YAMARKET_COMPANY_NAME', 'YAMARKET_DELIVERY_PRICE', 'YAMARKET_SALES_NOTES', 'YAMARKET_COUNTRY_OF_ORIGIN', 'YAMARKET_EXPORT_TYPE', 'YAMARKET_MODEL_NAME', 'YAMARKET_DESC_TYPE', 'YAMARKET_DELIVERY_DELIVERY', 'YAMARKET_DELIVERY_PICKUP', 'YAMARKET_DELIVERY_STORE');
$this->country_of_origin_attr = Configuration::get('YAMARKET_COUNTRY_OF_ORIGIN');
$this->model_name_attr = Configuration::get('YAMARKET_MODEL_NAME');
parent::__construct();
$this->displayName = $this->l('Yandex Market');
if ($this->id && !Configuration::get('YAMARKET_COMPANY_NAME')) {
$this->warning = $this->l('You have not yet set your Company Name');
}
$this->description = $this->l('Provides price list export to Yandex Market');
$this->confirmUninstall = $this->l('Are you sure you want to delete your details ?');
// Variables fro price list
$this->id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
$this->proto_prefix = _PS_BASE_URL_;
// Get groups
$attribute_groups = AttributeGroup::getAttributesGroups($this->id_lang);
$this->attibute_groups = array();
foreach ($attribute_groups as $group) {
$this->attibute_groups[$group['id_attribute_group']] = $group['public_name'];
}
// Get categories
$this->excluded_cats = explode(',', Configuration::get('TOPSHOP_EXCLUDED_CATS'));
if (!$this->excluded_cats) {
$this->excluded_cats = array();
}
$all_cats = Category::getSimpleCategories($this->id_lang);
$this->selected_cats = array();
$this->all_cats = array();
foreach ($all_cats as $cat) {
$this->all_cats[] = $cat['id_category'];
if (!in_array($cat['id_category'], $this->excluded_cats)) {
$this->selected_cats[] = $cat['id_category'];
}
}
//determine image type
$this->image_type = 'large_default';
if (Tools::substr(_PS_VERSION_, 0, 5) == '1.5.0') {
$this->image_type = 'large';
}
}
示例7: get_index
public function get_index($cat = '', $alias = '')
{
//Filtering the Attribute groups for product specific
if (empty($alias)) {
}
$prod = Product::with(array('getCategory', 'getCategory.getDescriptions'))->where('alias', '=', $cat)->first();
$cat = $prod->getCategory[0]->getDescriptions->alias;
$alias = $prod->alias;
$category_id = CategoryDescription::with('getCategory')->where('alias', '=', $cat)->only('id');
$result = Category::with(array("getDescriptions", "getTopCat", "getTopCat.getDescriptions", "getProducts" => function ($query) use($alias) {
$query->where('alias', '=', $alias);
}, "getProducts.getBrand", "getProducts.getImages", "getProducts.getDetail", "getProducts.getTax", "getProducts.getDiscount", "getProducts.getAttributes", "getProducts.getShipment", "getAttributeListing", "getAttributeListing.getTopGroup"))->where('id', '=', $category_id)->first();
Title::put($result->getProducts[0]->getDetail->name);
/*Get attributes*/
$topGroups = array();
foreach ($result->getAttributeListing as $item) {
array_push($topGroups, $item->getTopGroup->id);
}
$topGroups = array_unique($topGroups);
$groups = array();
foreach ($result->getAttributeListing as $item) {
array_push($groups, $item->id);
}
$groups = array_unique($groups);
$belongedGroups = array();
foreach ($result->getProducts[0]->getAttributes as $item) {
array_push($belongedGroups, $item->id);
}
$attrs = AttributeGroup::with(array('getParentGroup' => function ($query) use($groups) {
$query->order_by('sort_order', 'desc');
$query->where_in('id', $groups);
}, 'getParentGroup.getAttributes' => function ($query) use($belongedGroups) {
$query->where_in('id', $belongedGroups);
}))->where_in('id', $topGroups)->get();
return View::make('products.index')->with('product', $result)->with('attrs', $attrs);
}
示例8: renderForm
public function renderForm()
{
$back = Tools::safeOutput(Tools::getValue('back', ''));
if (empty($back)) {
$back = self::$currentIndex . '&token=' . $this->token;
}
$this->toolbar_btn['save-and-stay'] = array('href' => '#', 'desc' => $this->l('Save and Stay'));
$current_object = $this->loadObject(true);
// All the filter are prefilled with the correct information
$customer_filter = '';
if (Validate::isUnsignedId($current_object->id_customer) && ($customer = new Customer($current_object->id_customer)) && Validate::isLoadedObject($customer)) {
$customer_filter = $customer->firstname . ' ' . $customer->lastname . ' (' . $customer->email . ')';
}
$gift_product_filter = '';
if (Validate::isUnsignedId($current_object->gift_product) && ($product = new Product($current_object->gift_product, false, $this->context->language->id)) && Validate::isLoadedObject($product)) {
$gift_product_filter = !empty($product->reference) ? $product->reference : $product->name;
}
$reduction_product_filter = '';
if (Validate::isUnsignedId($current_object->reduction_product) && ($product = new Product($current_object->reduction_product, false, $this->context->language->id)) && Validate::isLoadedObject($product)) {
$reduction_product_filter = !empty($product->reference) ? $product->reference : $product->name;
}
$product_rule_groups = $this->getProductRuleGroupsDisplay($current_object);
$attribute_groups = AttributeGroup::getAttributesGroups($this->context->language->id);
$currencies = Currency::getCurrencies();
$languages = Language::getLanguages();
$countries = $current_object->getAssociatedRestrictions('country', true, true);
$groups = $current_object->getAssociatedRestrictions('group', false, true);
$shops = $current_object->getAssociatedRestrictions('shop', false, false);
$cart_rules = $current_object->getAssociatedRestrictions('cart_rule', false, true);
$carriers = $current_object->getAssociatedRestrictions('carrier', true, false);
foreach ($carriers as &$carriers2) {
foreach ($carriers2 as &$carrier) {
foreach ($carrier as $field => &$value) {
if ($field == 'name' && $value == '0') {
$value = Configuration::get('PS_SHOP_NAME');
}
}
}
}
$gift_product_select = '';
$gift_product_attribute_select = '';
if ((int) $current_object->gift_product) {
$search_products = $this->searchProducts($gift_product_filter);
foreach ($search_products['products'] as $product) {
$gift_product_select .= '
<option value="' . $product['id_product'] . '" ' . ($product['id_product'] == $current_object->gift_product ? 'selected="selected"' : '') . '>
' . $product['name'] . (count($product['combinations']) == 0 ? ' - ' . $product['formatted_price'] : '') . '
</option>';
if (count($product['combinations'])) {
$gift_product_attribute_select .= '<select class="id_product_attribute" id="ipa_' . $product['id_product'] . '" name="ipa_' . $product['id_product'] . '">';
foreach ($product['combinations'] as $combination) {
$gift_product_attribute_select .= '
<option ' . ($combination['id_product_attribute'] == $current_object->gift_product_attribute ? 'selected="selected"' : '') . ' value="' . $combination['id_product_attribute'] . '">
' . $combination['attributes'] . ' - ' . $combination['formatted_price'] . '
</option>';
}
$gift_product_attribute_select .= '</select>';
}
}
}
$product = new Product($current_object->gift_product);
$this->context->smarty->assign(array('show_toolbar' => true, 'toolbar_btn' => $this->toolbar_btn, 'toolbar_scroll' => $this->toolbar_scroll, 'title' => array($this->l('Payment: '), $this->l('Cart Rules')), 'defaultDateFrom' => date('Y-m-d H:00:00'), 'defaultDateTo' => date('Y-m-d H:00:00', strtotime('+1 month')), 'customerFilter' => $customer_filter, 'giftProductFilter' => $gift_product_filter, 'gift_product_select' => $gift_product_select, 'gift_product_attribute_select' => $gift_product_attribute_select, 'reductionProductFilter' => $reduction_product_filter, 'defaultCurrency' => Configuration::get('PS_CURRENCY_DEFAULT'), 'id_lang_default' => Configuration::get('PS_LANG_DEFAULT'), 'languages' => $languages, 'currencies' => $currencies, 'countries' => $countries, 'carriers' => $carriers, 'groups' => $groups, 'shops' => $shops, 'cart_rules' => $cart_rules, 'product_rule_groups' => $product_rule_groups, 'product_rule_groups_counter' => count($product_rule_groups), 'attribute_groups' => $attribute_groups, 'currentIndex' => self::$currentIndex, 'currentToken' => $this->token, 'currentObject' => $current_object, 'currentTab' => $this, 'hasAttribute' => $product->hasAttributes()));
$this->content .= $this->createTemplate('form.tpl')->fetch();
$this->addJqueryUI('ui.datepicker');
return parent::renderForm();
}
示例9: getContent
public function getContent()
{
$this->html = '';
if (Tools::isSubmit('submitNetEven')) {
if (Tools::getValue('NETEVEN_LOGIN') && Tools::getValue('NETEVEN_PASSWORD')) {
Gateway::updateConfig('NETEVEN_LOGIN', Tools::getValue('NETEVEN_LOGIN'));
Gateway::updateConfig('NETEVEN_PASSWORD', Tools::getValue('NETEVEN_PASSWORD'));
Gateway::updateConfig('COMMENT', Tools::getValue('COMMENT'));
Gateway::updateConfig('DEFAULT_BRAND', Tools::getValue('DEFAULT_BRAND'));
Gateway::updateConfig('IMAGE_TYPE_NAME', Tools::getValue('IMAGE_TYPE_NAME'));
Gateway::updateConfig('SYNCHRONISATION_ORDER', (int) Tools::getValue('SYNCHRONISATION_ORDER'));
Gateway::updateConfig('SYNCHRONISATION_PRODUCT', (int) Tools::getValue('SYNCHRONISATION_PRODUCT'));
Gateway::updateConfig('TYPE_SKU', (string) Tools::getValue('TYPE_SKU'));
$this->html .= $this->displayConfirmation($this->l('Les paramètres ont bien été mis à jour'));
} else {
$this->html .= $this->displayError($this->l('Les login et mot de passe NetEven sont obligatoire'));
}
} elseif (Tools::isSubmit('submitNetEvenShipping')) {
Gateway::updateConfig('SHIPPING_DELAY', Tools::getValue('SHIPPING_DELAY'));
Gateway::updateConfig('SHIPPING_PRICE_LOCAL', Tools::getValue('SHIPPING_PRICE_LOCAL'));
Gateway::updateConfig('SHIPPING_PRICE_INTERNATIONAL', Tools::getValue('SHIPPING_PRICE_INTERNATIONAL'));
Gateway::updateConfig('SHIPPING_BY_PRODUCT', (int) Tools::getValue('SHIPPING_BY_PRODUCT'));
Gateway::updateConfig('SHIPPING_BY_PRODUCT_FIELDNAME', Tools::getValue('SHIPPING_BY_PRODUCT_FIELDNAME'));
Gateway::updateConfig('SHIPPING_CARRIER_FRANCE', Tools::getValue('SHIPPING_CARRIER_FRANCE'));
Gateway::updateConfig('SHIPPING_ZONE_FRANCE', Tools::getValue('SHIPPING_ZONE_FRANCE'));
Gateway::updateConfig('SHIPPING_CARRIER_INTERNATIONAL', Tools::getValue('SHIPPING_CARRIER_INTERNATIONAL'));
Gateway::updateConfig('SHIPPING_ZONE_INTERNATIONAL', Tools::getValue('SHIPPING_ZONE_INTERNATIONAL'));
$this->html .= $this->displayConfirmation($this->l('Les paramètres de livraison ont bien été mis à jour'));
} elseif (Tools::isSubmit('submitDev')) {
Gateway::updateConfig('NETEVEN_URL', Tools::getValue('NETEVEN_URL'));
Gateway::updateConfig('NETEVEN_NS', Tools::getValue('NETEVEN_NS'));
Gateway::updateConfig('MAIL_LIST_ALERT', Tools::getValue('MAIL_LIST_ALERT'));
Gateway::updateConfig('DEBUG', (int) Tools::getValue('DEBUG'));
Gateway::updateConfig('SEND_REQUEST_BY_EMAIL', (int) Tools::getValue('SEND_REQUEST_BY_EMAIL'));
$this->html .= $this->displayConfirmation($this->l('Les paramètres de maintenance ont bien été mis à jour'));
} elseif (Tools::isSubmit('submitCustomizableFeilds')) {
$customizable_field_name = Tools::getValue('customizable_field_name');
$customizable_field_value = Tools::getValue('customizable_field_value');
$customizable_string = '';
foreach ($customizable_field_name as $key => $value) {
if (!$customizable_field_name[$key] || !$customizable_field_value[$key]) {
continue;
}
if ($customizable_string) {
$customizable_string .= '¤';
}
$customizable_string .= $customizable_field_name[$key] . '|' . $customizable_field_value[$key];
}
Gateway::updateConfig('CUSTOMIZABLE_FIELDS', $customizable_string);
}
// Lists of order status
$order_states = OrderState::getOrderStates((int) $this->context->cookie->id_lang);
// Lists of features
$features = Feature::getFeatures((int) $this->context->cookie->id_lang);
// Lists of attribute groups
$attribute_groups = AttributeGroup::getAttributesGroups((int) $this->context->cookie->id_lang);
$neteven_features = Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . 'orders_gateway_feature`');
$neteven_feature_categories = array();
foreach ($neteven_features as $neteven_feature) {
if (!isset($neteven_feature_categories[$neteven_feature['category']])) {
$neteven_feature_categories[$neteven_feature['category']] = array();
}
$neteven_feature_categories[$neteven_feature['category']][] = $neteven_feature;
}
if ($this->getSOAP()) {
$this->html .= $this->displayForm($order_states, $features, $attribute_groups, $neteven_feature_categories);
} else {
$this->html .= $this->displayError($this->l('This module requires the SOAP extension to run'));
}
return $this->html;
}
示例10: ajaxProcessUpdateGroupsPositions
public function ajaxProcessUpdateGroupsPositions()
{
$way = (int) Tools::getValue('way');
$id_attribute_group = (int) Tools::getValue('id_attribute_group');
$positions = Tools::getValue('attribute_group');
$new_positions = array();
foreach ($positions as $k => $v) {
if (count(explode('_', $v)) == 4) {
$new_positions[] = $v;
}
}
foreach ($new_positions as $position => $value) {
$pos = explode('_', $value);
if (isset($pos[2]) && (int) $pos[2] === $id_attribute_group) {
if ($group_attribute = new AttributeGroup((int) $pos[2])) {
if (isset($position) && $group_attribute->updatePosition($way, $position)) {
echo 'ok position ' . (int) $position . ' for group attribute ' . (int) $pos[2] . '\\r\\n';
} else {
echo '{"hasError" : true, "errors" : "Can not update group attribute ' . (int) $id_attribute_group . ' to position ' . (int) $position . ' "}';
}
} else {
echo '{"hasError" : true, "errors" : "This group attribute (' . (int) $id_attribute_group . ') can t be loaded"}';
}
break;
}
}
}
示例11: AttributeGroup
<?php
if (Tools::Q('saveAttributeGroup') == 'add') {
$attribute_group = new AttributeGroup();
$attribute_group->copyFromPost();
$attribute_group->add();
if (is_array($attribute_group->_errors) and count($attribute_group->_errors) > 0) {
$errors = $attribute_group->_errors;
} else {
$_GET['id'] = $attribute_group->id;
UIAdminAlerts::conf('已添加属性组');
}
}
if (isset($_GET['id'])) {
$id = (int) Tools::G('id');
$obj = new AttributeGroup($id);
}
if (Tools::Q('saveAttributeGroup') == 'edit') {
if (Validate::isLoadedObject($obj)) {
$obj->copyFromPost();
$obj->update();
}
if (is_array($obj->_errors) and count($obj->_errors) > 0) {
$errors = $obj->_errors;
} else {
UIAdminAlerts::conf('已更新属性组');
}
}
if (isset($errors)) {
UIAdminAlerts::MError($errors);
}
示例12: attributeImportOne
//.........这里部分代码省略.........
}
}
}
if (empty($id_image)) {
$this->warnings[] = sprintf($this->trans('No image was found for combination with id_product = %s and image position = %s.', array(), 'Admin.Parameters.Notification'), $product->id, (int) $position);
}
}
}
}
$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) {
示例13: initContentForCombinations
public function initContentForCombinations()
{
${${"GLOBALS"}["vmqqtmkyw"]} = $this->object;
if (!Combination::isFeatureActive()) {
$this->displayWarning($this->getMessage("This feature has been disabled, you can activate this feature at this page:") . $this->getMessage("link to Performances"));
return;
}
${"GLOBALS"}["weevwwkl"] = "product";
if (Validate::isLoadedObject(${${"GLOBALS"}["weevwwkl"]})) {
self::$smarty->assign("country_display_tax_label", $this->context->country->display_tax_label);
$zsahvowoo = "lang";
self::$smarty->assign("tax_exclude_taxe_option", Tax::excludeTaxeOption());
self::$smarty->assign("id_tax_rules_group", $product->id_tax_rules_group);
self::$smarty->assign("tax_rules_groups", TaxRulesGroup::getTaxRulesGroups(true));
${$zsahvowoo} = new Language($this->id_language);
self::$smarty->assign("iso_code", $lang->iso_code);
self::$smarty->assign("combinationImagesJs", $this->getCombinationImagesJs());
if ($product->is_virtual) {
$tpkpvyor = "product";
self::$smarty->assign("product", ${$tpkpvyor});
$this->displayWarning($this->getMessage("A virtual product cannot have combinations."));
} else {
${"GLOBALS"}["qqjbnscylsi"] = "attribute_js";
${"GLOBALS"}["nqxaoftbn"] = "attribute";
$bcesaxqdqqq = "images";
${"GLOBALS"}["zcxmuajd"] = "ps_stock_mvt_reason_default";
$vmytjghdfi = "attribute_js";
$nrkrfhirkx = "attributes";
${${"GLOBALS"}["qqjbnscylsi"]} = array();
$cappytc = "k";
${"GLOBALS"}["jyaoxpe"] = "attribute";
${$nrkrfhirkx} = Attribute::getAttributes($this->context->language->id, true);
foreach (${${"GLOBALS"}["ecblflvypvt"]} as ${$cappytc} => ${${"GLOBALS"}["jyaoxpe"]}) {
${$vmytjghdfi}[${${"GLOBALS"}["iixdipeiyldv"]}["id_attribute_group"]][${${"GLOBALS"}["iixdipeiyldv"]}["id_attribute"]] = ${${"GLOBALS"}["nqxaoftbn"]}["name"];
}
${"GLOBALS"}["higiwiyuxd"] = "k";
${${"GLOBALS"}["sxexnhlq"]} = new Currency((int) Configuration::get("PS_CURRENCY_DEFAULT"));
self::$smarty->assign("attributeJs", ${${"GLOBALS"}["xenfvrjowsy"]});
self::$smarty->assign("attributes_groups", AttributeGroup::getAttributesGroups($this->context->language->id));
self::$smarty->assign("currency", ${${"GLOBALS"}["sxexnhlq"]});
${"GLOBALS"}["xzqtsdnlkv"] = "images";
${$bcesaxqdqqq} = Image::getImages($this->context->language->id, $product->id);
self::$smarty->assign("tax_exclude_option", Tax::excludeTaxeOption());
$rbxbrbxg = "product";
self::$smarty->assign("ps_weight_unit", Configuration::get("PS_WEIGHT_UNIT"));
self::$smarty->assign("ps_use_ecotax", Configuration::get("PS_USE_ECOTAX"));
self::$smarty->assign("field_value_unity", $this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "unity"));
${"GLOBALS"}["vpcuib"] = "image_type";
self::$smarty->assign("reasons", ${${"GLOBALS"}["nqegxbae"]} = StockMvtReason::getStockMvtReasons($this->context->language->id));
self::$smarty->assign("ps_stock_mvt_reason_default", ${${"GLOBALS"}["zcxmuajd"]} = Configuration::get("PS_STOCK_MVT_REASON_DEFAULT"));
self::$smarty->assign("minimal_quantity", $this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "minimal_quantity") ? $this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "minimal_quantity") : 1);
self::$smarty->assign("available_date", $this->getFieldValue(${$rbxbrbxg}, "available_date") != 0 ? stripslashes(htmlentities(Tools::displayDate($this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "available_date"), version_compare(_PS_VERSION_, "1.5.5", ">=") ? null : $this->context->language->id))) : "0000-00-00");
${${"GLOBALS"}["tqkkuicfgax"]} = 0;
${"GLOBALS"}["ucamhp"] = "product";
self::$smarty->assign("imageType", ImageType::getByNameNType("small_default", "products"));
self::$smarty->assign("imageWidth", (isset(${${"GLOBALS"}["rvkjjxqs"]}["width"]) ? (int) ${${"GLOBALS"}["vpcuib"]}["width"] : 64) + 25);
foreach (${${"GLOBALS"}["xzqtsdnlkv"]} as ${${"GLOBALS"}["higiwiyuxd"]} => ${${"GLOBALS"}["inpuwydsyk"]}) {
$cshrlmyryz = "image";
${${"GLOBALS"}["dhvuermstcbs"]}[${${"GLOBALS"}["qtxqhylrbsm"]}]["obj"] = new Image(${$cshrlmyryz}["id_image"]);
$kcvbkys = "i";
++${$kcvbkys};
}
self::$smarty->assign("images", ${${"GLOBALS"}["dhvuermstcbs"]});
self::$smarty->assign(array("combinationArray" => $this->getCombinations(${${"GLOBALS"}["ucamhp"]}, ${${"GLOBALS"}["sxexnhlq"]}), "product" => ${${"GLOBALS"}["vmqqtmkyw"]}, "id_category" => $product->getDefaultCategory(), "token_generator" => "tokengenerator", "combination_exists" => Shop::isFeatureActive() && Shop::getContextShopGroup()->share_stock && count(AttributeGroup::getAttributesGroups($this->context->language->id)) > 0));
}
} else {
self::$smarty->assign("product", ${${"GLOBALS"}["vmqqtmkyw"]});
$this->displayWarning($this->getMessage("You must save this product before adding combinations."));
}
}
示例14: attributeImport
public function attributeImport()
{
$default_language = Configuration::get('PS_LANG_DEFAULT');
$groups = array();
foreach (AttributeGroup::getAttributesGroups($default_language) as $group) {
$groups[$group['name']] = (int) $group['id_attribute_group'];
}
$attributes = array();
foreach (Attribute::getAttributes($default_language) as $attribute) {
$attributes[$attribute['attribute_group'] . '_' . $attribute['name']] = (int) $attribute['id_attribute'];
}
$this->receiveTab();
$handle = $this->openCsvFile();
AdminImportController::setLocale();
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
if (count($line) == 1 && empty($line[0])) {
continue;
}
if (Tools::getValue('convert')) {
$line = $this->utf8EncodeArray($line);
}
$info = AdminImportController::getMaskedRow($line);
$info = array_map('trim', $info);
AdminImportController::setDefaultValues($info);
if (!Shop::isFeatureActive()) {
$info['shop'] = 1;
} elseif (!isset($info['shop']) || empty($info['shop'])) {
$info['shop'] = implode($this->multiple_value_separator, Shop::getContextListShopID());
}
// Get shops for each attributes
$info['shop'] = explode($this->multiple_value_separator, $info['shop']);
$id_shop_list = array();
foreach ($info['shop'] as $shop) {
if (!is_numeric($shop)) {
$id_shop_list[] = Shop::getIdByName($shop);
} else {
$id_shop_list[] = $shop;
}
}
if (isset($info['id_product'])) {
$product = new Product((int) $info['id_product'], false, $default_language);
} else {
continue;
}
$id_image = null;
//delete existing images if "delete_existing_images" is set to 1
if (array_key_exists('delete_existing_images', $info) && $info['delete_existing_images'] && !isset($this->cache_image_deleted[(int) $product->id])) {
$product->deleteImages();
$this->cache_image_deleted[(int) $product->id] = true;
}
if (isset($info['image_url']) && $info['image_url']) {
$product_has_images = (bool) Image::getImages($this->context->language->id, $product->id);
$url = $info['image_url'];
$image = new Image();
$image->id_product = (int) $product->id;
$image->position = Image::getHighestPosition($product->id) + 1;
$image->cover = !$product_has_images ? true : false;
$field_error = $image->validateFields(UNFRIENDLY_ERROR, true);
$lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true);
if ($field_error === true && $lang_field_error === true && $image->add()) {
$image->associateTo($id_shop_list);
if (!AdminImportController::copyImg($product->id, $image->id, $url)) {
$this->warnings[] = sprintf(Tools::displayError('Error copying image: %s'), $url);
$image->delete();
} else {
$id_image = array($image->id);
}
} else {
$this->warnings[] = sprintf(Tools::displayError('%s cannot be saved'), isset($image->id_product) ? ' (' . $image->id_product . ')' : '');
$this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . mysql_error();
}
} elseif (isset($info['image_position']) && $info['image_position']) {
$images = $product->getImages($default_language);
if ($images) {
foreach ($images as $row) {
if ($row['position'] == (int) $info['image_position']) {
$id_image = array($row['id_image']);
break;
}
}
}
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
//.........这里部分代码省略.........
示例15: displayForm
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
$jsAttributes = self::displayAndReturnAttributeJs();
$attributesGroups = AttributeGroup::getAttributesGroups((int) $cookie->id_lang);
$this->product = new Product((int) Tools::getValue('id_product'));
// JS Init
echo '<script type="text/javascript">
i18n_tax_exc = "' . $this->l('Tax Excl.:') . '";
i18n_tax_inc = "' . $this->l('Tax Incl.:') . '";
var product_tax = "' . Tax::getProductTaxRate($this->product->id, NULL) . '";
function calcPrice(element, element_has_tax)
{
name = element.attr("name");
var element_price = element.val().replace(/,/g, ".");
var other_element_price = "0";
if (!isNaN(element_price) && element_price > 0)
{
if (element_has_tax)
other_element_price = parseFloat(element_price / ((product_tax / 100) + 1));
else
other_element_price = ps_round(parseFloat(element_price * ((product_tax / 100) + 1)), 2);
}
$("#related_to_"+name).val(other_element_price);
}
$(document).ready(function()
{
$(".price_impact").each(function()
{
calcPrice($(this), false);
});
});
</script>';
if (isset($_POST['generate']) and !sizeof($this->_errors)) {
echo '
<div class="module_confirmation conf confirm">
<img src="../img/admin/ok.gif" alt="" title="" style="margin-right:5px; float:left;" />
' . sizeof($this->combinations) . ' ' . $this->l('product(s) successfully created.') . '
</div>';
}
echo '
<script type="text/javascript" src="../js/attributesBack.js"></script>
<form enctype="multipart/form-data" method="post" id="generator" action="' . $currentIndex . '&&id_product=' . (int) Tools::getValue('id_product') . '&id_category=' . (int) Tools::getValue('id_category') . '&attributegenerator&token=' . Tools::getValue('token') . '">
<fieldset style="margin-bottom: 35px;"><legend><img src="../img/admin/asterisk.gif" />' . $this->l('Attributes generator') . '</legend>' . $this->l('Add or modify attributes for product:') . ' <b>' . $this->product->name[$cookie->id_lang] . '</b>
<br /><br />
';
echo '
<div style="padding-top:10px; float: left; width: 570px;">
<div style="float:left;">
<label>' . $this->l('Quantity') . '</label>
<div class="margin-form">
<input type="text" size="20" name="quantity" value="0"/>
</div>
<label>' . $this->l('Reference') . '</label>
<div class="margin-form">
<input type="text" size="20" name="reference" value="' . $this->product->reference . '"/>
</div>
</div>
<div style="float:left; text-align:center; margin-left:20px;">
<input type="submit" class="button" style="margin-bottom:5px;" name="generate" value="' . $this->l('Generate') . '" /><br />
<input type="submit" class="button" name="back" value="' . $this->l('Back to product') . '" />
</div>
<br style="clear:both;" />
<div style="margin-top: 15px;">';
self::displayGroupeTable($jsAttributes, $attributesGroups);
echo '
</div>
</div>
<div style="float: left; margin-left: 60px;">
';
self::displayGroupSelect($jsAttributes, $attributesGroups);
echo '
<div>
<p style="text-align: center;">
<input class="button" type="button" style="margin: 0 0 10px 20px;" value="' . $this->l('Add') . '" class="button" onclick="add_attr_multiple();" />
<input class="button" type="button" style="margin: 0 0 10px 20px;" value="' . $this->l('Delete') . '" class="button" onclick="del_attr_multiple();" /><br />
<input type="submit" class="button" name="back" value="' . $this->l('Back to product') . '" />
</p>
</div>
</div>
<br />
</fieldset>
</form>';
}