本文整理汇总了PHP中FeatureValue类的典型用法代码示例。如果您正苦于以下问题:PHP FeatureValue类的具体用法?PHP FeatureValue怎么用?PHP FeatureValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FeatureValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: addCustomFeatureToProductId
/**
* Add a custom feature to a product
* @param int $id_product
* @param int $id_feature
* @param int $id_lang
* @param array $values
*/
public static function addCustomFeatureToProductId($id_product, $id_feature, $id_lang, $values)
{
if (empty($id_product) || empty($id_feature) || empty($id_lang) || empty($values)) {
return false;
}
// Create the new custom feature
$custom_feature_value = new FeatureValue();
$custom_feature_value->id_feature = (int) $id_feature;
$custom_feature_value->custom = (bool) true;
$custom_feature_value->value = $values;
$custom_feature_value->add();
// Associate the new feature to product
self::addFeatureToProduct($id_product, $id_feature, $custom_feature_value->id);
}
开发者ID:quadra-informatique,项目名称:MultiFeature-Prestashop,代码行数:21,代码来源:QiMultiFeatureApi.php
示例2: renderForm
public function renderForm()
{
if (!$this->object->id) {
$this->object->price = -1;
}
$this->fields_form = array('legend' => array('title' => $this->l('Catalog price rules'), 'icon' => 'icon-dollar'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'maxlength' => 32, 'required' => true, 'hint' => $this->l('Forbidden characters') . ' <>;=#{}'), array('type' => 'select', 'label' => $this->l('Shop'), 'name' => 'shop_id', 'options' => array('query' => Shop::getShops(), 'id' => 'id_shop', 'name' => 'name'), 'condition' => Shop::isFeatureActive(), 'default_value' => Shop::getContextShopID()), array('type' => 'select', 'label' => $this->l('Currency'), 'name' => 'id_currency', 'options' => array('query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->l('All currencies'))), Currency::getCurrencies()), 'id' => 'id_currency', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'options' => array('query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->l('All countries'))), Country::getCountries((int) $this->context->language->id)), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Group'), 'name' => 'id_group', 'options' => array('query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->l('All groups'))), Group::getGroups((int) $this->context->language->id)), 'id' => 'id_group', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('From quantity'), 'name' => 'from_quantity', 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->l('Price (tax excl.)'), 'name' => 'price', 'disabled' => $this->object->price == -1 ? 1 : 0, 'maxlength' => 10, 'suffix' => $this->context->currency->getSign('right')), array('type' => 'checkbox', 'name' => 'leave_bprice', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Leave base price'), 'val' => '1', 'checked' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'datetime', 'label' => $this->l('From'), 'name' => 'from'), array('type' => 'datetime', 'label' => $this->l('To'), 'name' => 'to'), array('type' => 'select', 'label' => $this->l('Reduction type'), 'name' => 'reduction_type', 'options' => array('query' => array(array('reduction_type' => 'amount', 'name' => $this->l('Amount')), array('reduction_type' => 'percentage', 'name' => $this->l('Percentage'))), 'id' => 'reduction_type', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Reduction with or without taxes'), 'name' => 'reduction_tax', 'align' => 'center', 'options' => array('query' => array(array('lab' => $this->l('Tax included'), 'val' => 1), array('lab' => $this->l('Tax excluded'), 'val' => 0)), 'id' => 'val', 'name' => 'lab')), array('type' => 'text', 'label' => $this->l('Reduction'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->l('Save')));
if (($value = $this->getFieldValue($this->object, 'price')) != -1) {
$price = number_format($value, 6);
} else {
$price = '';
}
$this->fields_value = array('price' => $price, 'from_quantity' => ($value = $this->getFieldValue($this->object, 'from_quantity')) ? $value : 1, 'reduction' => number_format(($value = $this->getFieldValue($this->object, 'reduction')) ? $value : 0, 6), 'leave_bprice_on' => $price ? 0 : 1);
$attribute_groups = array();
$attributes = Attribute::getAttributes((int) $this->context->language->id);
foreach ($attributes as $attribute) {
if (!isset($attribute_groups[$attribute['id_attribute_group']])) {
$attribute_groups[$attribute['id_attribute_group']] = array('id_attribute_group' => $attribute['id_attribute_group'], 'name' => $attribute['attribute_group']);
}
$attribute_groups[$attribute['id_attribute_group']]['attributes'][] = array('id_attribute' => $attribute['id_attribute'], 'name' => $attribute['name']);
}
$features = Feature::getFeatures((int) $this->context->language->id);
foreach ($features as &$feature) {
$feature['values'] = FeatureValue::getFeatureValuesWithLang((int) $this->context->language->id, $feature['id_feature'], true);
}
$this->tpl_form_vars = array('manufacturers' => Manufacturer::getManufacturers(), 'suppliers' => Supplier::getSuppliers(), 'attributes_group' => $attribute_groups, 'features' => $features, 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'conditions' => $this->object->getConditions(), 'is_multishop' => Shop::isFeatureActive());
return parent::renderForm();
}
开发者ID:jpodracky,项目名称:dogs,代码行数:27,代码来源:AdminSpecificPriceRuleController.php
示例3: add
/**
* @param bool $autodate
* @param bool $nullValues
* @return bool
*/
public function add($autodate = true, $nullValues = false)
{
if ($this->position <= 0) {
$this->position = FeatureValue::getHigherPosition($this->id_feature) + 1;
}
return parent::add($autodate, $nullValues);
}
开发者ID:TheTypoMaster,项目名称:neonflexible,代码行数:12,代码来源:FeatureValue.php
示例4: add
public function add($autodate = true, $null_values = false)
{
if ($this->position <= 0) {
$this->position = FeatureValue::getHigherPosition($this->id_feature) + 1;
}
$return = parent::add($autodate, $null_values);
if ($return) {
Hook::exec('actionFeatureValueSave', array('id_feature_value' => $this->id));
}
return $return;
}
开发者ID:hantonius,项目名称:advancedfeaturesvalues,代码行数:11,代码来源:FeatureValue.php
示例5: initFormFeatures
public function initFormFeatures($obj)
{
if (!$this->default_form_language) {
$this->getLanguages();
}
$tpl_path = _PS_MODULE_DIR_ . 'advancedfeaturesvalues/views/templates/admin/products/features.tpl';
$data = $this->context->smarty->createTemplate($tpl_path, $this->context->smarty);
$data->assign('default_form_language', $this->default_form_language);
$data->assign('languages', $this->_languages);
if (!Feature::isFeatureActive()) {
$this->displayWarning($this->l('This feature has been disabled. ') . '
<a href="index.php?tab=AdminPerformance&token=' . Tools::getAdminTokenLite('AdminPerformance') . '#featuresDetachables">' . $this->l('Performances') . '</a>');
} else {
if ($obj->id) {
if ($this->product_exists_in_shop) {
$features = Feature::getFeatures($this->context->language->id, Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP);
foreach ($features as $k => $tab_features) {
$features[$k]['current_item'] = array();
$features[$k]['val'] = array();
$custom = true;
foreach ($obj->getFeatures() as $tab_products) {
if ($tab_products['id_feature'] == $tab_features['id_feature']) {
$features[$k]['current_item'][] = $tab_products['id_feature_value'];
}
}
$features[$k]['featureValues'] = FeatureValue::getFeatureValuesWithLang($this->context->language->id, (int) $tab_features['id_feature']);
if (count($features[$k]['featureValues'])) {
foreach ($features[$k]['featureValues'] as $value) {
if (in_array($value['id_feature_value'], $features[$k]['current_item'])) {
$custom = false;
}
}
}
if ($custom && !empty($features[$k]['current_item'])) {
$features[$k]['val'] = FeatureValue::getFeatureValueLang($features[$k]['current_item'][0]);
}
}
$data->assign('available_features', $features);
$data->assign('product', $obj);
$data->assign('link', $this->context->link);
$data->assign('default_form_language', $this->default_form_language);
} else {
$this->displayWarning($this->l('You must save the product in this shop before adding features.'));
}
} else {
$this->displayWarning($this->l('You must save this product before adding features.'));
}
}
$this->tpl_form_vars['custom_form'] = $data->fetch();
}
开发者ID:hantonius,项目名称:advancedfeaturesvalues,代码行数:50,代码来源:AdminProductsController.php
示例6: addFeature
public function addFeature($id_product, $feature_name, $feature_value)
{
if (empty($feature_value)) {
return;
}
$id_feature = Feature::addFeatureImport($feature_name);
$id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $feature_value);
Product::addFeatureProductImport($id_product, $id_feature, $id_feature_value);
}
开发者ID:priyankajsr19,项目名称:indusdiva2,代码行数:9,代码来源:AdminProductImport.php
示例7: productImport
//.........这里部分代码省略.........
$this->_errors[] = $categoryToCreate->name[$defaultLanguageId] . (isset($categoryToCreate->id) ? ' (' . $categoryToCreate->id . ')' : '') . ' ' . Tools::displayError('cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
}
} elseif (is_string($value) and !empty($value)) {
$category = Category::searchByName($defaultLanguageId, $value, true);
if ($category['id_category']) {
$product->id_category[] = intval($category['id_category']);
} else {
$categoryToCreate = new Category();
$categoryToCreate->name = self::createMultiLangField($value);
$categoryToCreate->active = 1;
$categoryToCreate->id_parent = 1;
// Default parent is home for unknown category to create
if (($fieldError = $categoryToCreate->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $categoryToCreate->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $categoryToCreate->add()) {
$product->id_category[] = intval($categoryToCreate->id);
} else {
$this->_errors[] = $categoryToCreate->name[$defaultLanguageId] . (isset($categoryToCreate->id) ? ' (' . $categoryToCreate->id . ')' : '') . ' ' . Tools::displayError('cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
}
}
}
}
$product->id_category_default = isset($product->id_category[0]) ? intval($product->id_category[0]) : '';
$link_rewrite = is_array($product->link_rewrite) ? $product->link_rewrite[$defaultLanguageId] : '';
$valid_link = Validate::isLinkRewrite($link_rewrite);
$bak = $product->link_rewrite;
if (isset($product->link_rewrite[$defaultLanguageId]) and empty($product->link_rewrite[$defaultLanguageId]) or !$valid_link) {
$link_rewrite = Tools::link_rewrite($product->name[$defaultLanguageId]);
}
if (!$valid_link) {
$this->_warnings[] = Tools::displayError('Rewrited link for') . ' ' . $bak . (isset($info['id']) ? ' (ID ' . $info['id'] . ') ' : '') . ' ' . Tools::displayError('was re-written as') . ' ' . $link_rewrite;
}
$product->link_rewrite = self::createMultiLangField($link_rewrite);
$res = false;
$fieldError = $product->validateFields(UNFRIENDLY_ERROR, true);
$langFieldError = $product->validateFieldsLang(UNFRIENDLY_ERROR, true);
if ($fieldError === true and $langFieldError === true) {
// check quantity
if ($product->quantity == NULL) {
$product->quantity = 0;
}
// If id product AND id product already in base, trying to update
if ($product->id and Product::existsInDatabase(intval($product->id))) {
$datas = Db::getInstance()->getRow('SELECT `date_add` FROM `' . _DB_PREFIX_ . 'product` WHERE `id_product` = ' . intval($product->id));
$product->date_add = pSQL($datas['date_add']);
$res = $product->update();
}
// If no id_product or update failed
if (!$res) {
$res = $product->add();
}
}
// If both failed, mysql error
if (!$res) {
$this->_errors[] = $info['name'] . (isset($info['id']) ? ' (ID ' . $info['id'] . ')' : '') . ' ' . Tools::displayError('cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
} else {
if (isset($product->tags) and !empty($product->tags)) {
$tag = new Tag();
$array = self::createMultiLangField($product->tags);
foreach ($array as $key => $tags) {
$a = $tag->addTags($key, $product->id, $tags);
}
}
if (isset($product->image) and is_array($product->image) and sizeof($product->image)) {
$productHasImages = (bool) Image::getImages(intval($cookie->id_lang), intval($product->id));
foreach ($product->image as $key => $url) {
if (!empty($url)) {
$image = new Image();
$image->id_product = intval($product->id);
$image->position = Image::getHighestPosition($product->id) + 1;
$image->cover = (!$key and !$productHasImages) ? true : false;
$image->legend = self::createMultiLangField($product->name[$defaultLanguageId]);
if (($fieldError = $image->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $image->add()) {
self::copyImg($product->id, $image->id, $url);
} else {
$this->_warnings[] = $image->legend[$defaultLanguageId] . (isset($image->id_product) ? ' (' . $image->id_product . ')' : '') . ' ' . Tools::displayError('cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
}
}
}
if (isset($product->id_category)) {
$product->updateCategories(array_map('intval', $product->id_category));
}
$features = get_object_vars($product);
foreach ($features as $feature => $value) {
if (!strncmp($feature, '#F_', 3) and Tools::strlen($product->{$feature})) {
$feature_name = str_replace('#F_', '', $feature);
$id_feature = Feature::addFeatureImport($feature_name);
$id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $product->{$feature});
Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
}
}
}
}
$this->closeCsvFile($handle);
}
开发者ID:Bruno-2M,项目名称:prestashop,代码行数:101,代码来源:AdminImport.php
示例8: initContentForFeatures
private function initContentForFeatures()
{
$tlwvvxr = "features";
${"GLOBALS"}["pihske"] = "features";
$jxbahojyvlt = "available_features_all";
$fotyrrre = "available_features_all";
$lueyeppw = "features";
${"GLOBALS"}["iavdbtipeie"] = "tab_features";
${$lueyeppw} = Feature::getFeatures($this->id_language);
foreach (${$tlwvvxr} as ${${"GLOBALS"}["qtxqhylrbsm"]} => ${${"GLOBALS"}["iavdbtipeie"]}) {
${"GLOBALS"}["ringgeomwho"] = "tab_products";
$oovownr = "k";
$dibecrefieyf = "k";
${"GLOBALS"}["llnriurbfb"] = "features";
${"GLOBALS"}["krrouj"] = "k";
${"GLOBALS"}["ezrxbtdf"] = "features";
${${"GLOBALS"}["nrjxzlhiqjg"]}[${${"GLOBALS"}["krrouj"]}]["current_item"] = false;
${${"GLOBALS"}["nrjxzlhiqjg"]}[${$dibecrefieyf}]["val"] = array();
${${"GLOBALS"}["vwmhyvovziq"]} = true;
foreach ($this->object->getFeatures() as ${${"GLOBALS"}["ringgeomwho"]}) {
$hozllwqodl = "features";
$koyfxiz = "k";
${"GLOBALS"}["hkqtkv"] = "tab_products";
${"GLOBALS"}["icrwrssx"] = "tab_products";
$wbqcupctp = "tab_features";
if (${${"GLOBALS"}["hkqtkv"]}["id_feature"] == ${$wbqcupctp}["id_feature"]) {
${$hozllwqodl}[${$koyfxiz}]["current_item"] = ${${"GLOBALS"}["icrwrssx"]}["id_feature_value"];
}
}
${${"GLOBALS"}["nrjxzlhiqjg"]}[${${"GLOBALS"}["qtxqhylrbsm"]}]["featureValues"] = FeatureValue::getFeatureValuesWithLang($this->id_language, (int) ${${"GLOBALS"}["kowgsfpm"]}["id_feature"]);
if (count(${${"GLOBALS"}["nrjxzlhiqjg"]}[${$oovownr}]["featureValues"])) {
$gtmlwoq = "features";
$ryjttmtpvt = "k";
foreach (${$gtmlwoq}[${$ryjttmtpvt}]["featureValues"] as ${${"GLOBALS"}["kzwkbwmzgtl"]}) {
$rtsfkxsq = "features";
$tduybwwrxb = "value";
if (${$rtsfkxsq}[${${"GLOBALS"}["qtxqhylrbsm"]}]["current_item"] == ${$tduybwwrxb}["id_feature_value"]) {
${${"GLOBALS"}["vwmhyvovziq"]} = false;
}
}
}
if (${${"GLOBALS"}["vwmhyvovziq"]}) {
${${"GLOBALS"}["llnriurbfb"]}[${${"GLOBALS"}["qtxqhylrbsm"]}]["val"] = FeatureValue::getFeatureValueLang(${${"GLOBALS"}["ezrxbtdf"]}[${${"GLOBALS"}["qtxqhylrbsm"]}]["current_item"]);
}
}
${$jxbahojyvlt} = "";
foreach (${${"GLOBALS"}["nrjxzlhiqjg"]} as ${${"GLOBALS"}["jtsfpdcbh"]}) {
${"GLOBALS"}["tpyuivnp"] = "available_features_all";
${${"GLOBALS"}["mogxjutudv"]} = ${${"GLOBALS"}["tpyuivnp"]} . "custom_" . ${${"GLOBALS"}["jtsfpdcbh"]}["id_feature"] . "¤";
}
self::$smarty->assign(array("available_features_all" => ${$fotyrrre}, "available_features" => ${${"GLOBALS"}["pihske"]}));
}
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:52,代码来源:sellerproductdetailbase.php
示例9: addFeatureValueImport
public static function addFeatureValueImport($id_feature, $name)
{
$rq = Db::getInstance()->executeS('
SELECT fv.`id_feature_value`
FROM ' . _DB_PREFIX_ . 'feature_value fv
LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl
ON (fvl.`id_feature_value` = fv.`id_feature_value`)
WHERE `value` = \'' . pSQL($name) . '\'
AND fv.`id_feature` = ' . (int) $id_feature . '
AND fv.`custom` = 1
GROUP BY fv.`id_feature_value` LIMIT 1
');
if (!isset($rq[0]['id_feature_value']) || !($id_feature_value = (int) $rq[0]['id_feature_value'])) {
// Feature doesn't exist, create it
$feature_value = new FeatureValue();
$languages = Language::getLanguages();
foreach ($languages as $language) {
$feature_value->value[$language['id_lang']] = strval($name);
}
$feature_value->id_feature = (int) $id_feature;
$feature_value->custom = 1;
$feature_value->add();
return (int) $feature_value->id;
}
return (int) $id_feature_value;
}
开发者ID:jicheng17,项目名称:vipinsg,代码行数:26,代码来源:FeatureValue.php
示例10: getFeatures
function getFeatures($prod_id)
{
$features = Product::getFeaturesStatic((int) $prod_id);
$params = array();
foreach ($features as $feature) {
$feature_name = Feature::getFeature($this->id_lang, $feature['id_feature']);
$feature_name = $feature_name['name'];
$feature_values = FeatureValue::getFeatureValueLang($feature['id_feature_value']);
$feature_value = null;
foreach ($feature_values as $f_value) {
$feature_value = $f_value['value'];
if ($f_value['id_lang'] == $this->id_lang) {
break;
}
}
if ($feature_value != null) {
$params[$feature_name] = $feature_value;
}
}
return $params;
}
开发者ID:WhisperingTree,项目名称:etagerca,代码行数:21,代码来源:topshop.php
示例11: displayFormFeatures
function displayFormFeatures($obj)
{
global $cookie, $currentIndex;
parent::displayForm();
if ($obj->id) {
$feature = Feature::getFeatures((int) $cookie->id_lang);
$ctab = '';
foreach ($feature as $tab) {
$ctab .= 'ccustom_' . $tab['id_feature'] . '¤';
}
$ctab = rtrim($ctab, '¤');
echo '
<table cellpadding="5">
<tr>
<td colspan="2">
<b>' . $this->l('Assign features to this product:') . '</b><br />
<ul style="margin: 10px 0 0 20px;">
<li>' . $this->l('You can specify a value for each relevant feature regarding this product, empty fields will not be displayed.') . '</li>
<li>' . $this->l('You can either set a specific value, or select among existing pre-defined values you added previously.') . '</li>
</ul>
</td>
</tr>
</table>
<hr style="width:100%;" /><br />';
// Header
$nb_feature = Feature::nbFeatures((int) $cookie->id_lang);
echo '
<table border="0" cellpadding="0" cellspacing="0" class="table" style="width:900px;">
<tr>
<th>' . $this->l('Feature') . '</td>
<th style="width:30%">' . $this->l('Pre-defined value') . '</td>
<th style="width:40%"><u>' . $this->l('or') . '</u> ' . $this->l('Customized value') . '</td>
</tr>';
if (!$nb_feature) {
echo '<tr><td colspan="3" style="text-align:center;">' . $this->l('No features defined') . '</td></tr>';
}
echo '</table>';
// Listing
if ($nb_feature) {
echo '
<table cellpadding="5" style="width: 900px; margin-top: 10px">';
foreach ($feature as $tab_features) {
$current_item = false;
$custom = true;
foreach ($obj->getFeatures() as $tab_products) {
if ($tab_products['id_feature'] == $tab_features['id_feature']) {
$current_item = $tab_products['id_feature_value'];
}
}
$featureValues = FeatureValue::getFeatureValuesWithLang((int) $cookie->id_lang, (int) $tab_features['id_feature']);
echo '
<tr>
<td>' . $tab_features['name'] . '</td>
<td style="width: 30%">';
if (sizeof($featureValues)) {
echo '
<select id="feature_' . $tab_features['id_feature'] . '_value" name="feature_' . $tab_features['id_feature'] . '_value"
onchange="$(\'.custom_' . $tab_features['id_feature'] . '_\').val(\'\');">
<option value="0">--- </option>';
foreach ($featureValues as $value) {
if ($current_item == $value['id_feature_value']) {
$custom = false;
}
echo '<option value="' . $value['id_feature_value'] . '"' . ($current_item == $value['id_feature_value'] ? ' selected="selected"' : '') . '>' . substr($value['value'], 0, 40) . (Tools::strlen($value['value']) > 40 ? '...' : '') . ' </option>';
}
echo '</select>';
} else {
echo '<input type="hidden" name="feature_' . $tab_features['id_feature'] . '_value" value="0" /><span style="font-size: 10px; color: #666;">' . $this->l('N/A') . ' - <a href="index.php?tab=AdminFeatures&addfeature_value&id_feature=' . (int) $tab_features['id_feature'] . '&token=' . Tools::getAdminToken('AdminFeatures' . (int) Tab::getIdFromClassName('AdminFeatures') . (int) $cookie->id_employee) . '" style="color: #666; text-decoration: underline;">' . $this->l('Add pre-defined values first') . '</a></span>';
}
echo '
</td>
<td style="width:40%" class="translatable">';
$tab_customs = $custom ? FeatureValue::getFeatureValueLang($current_item) : array();
foreach ($this->_languages as $language) {
echo '
<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
<textarea class="custom_' . $tab_features['id_feature'] . '_" name="custom_' . $tab_features['id_feature'] . '_' . $language['id_lang'] . '" cols="40" rows="1"
onkeyup="if (isArrowKey(event)) return ;$(\'#feature_' . $tab_features['id_feature'] . '_value\').val(0);" >' . htmlentities(Tools::getValue('custom_' . $tab_features['id_feature'] . '_' . $language['id_lang'], FeatureValue::selectLang($tab_customs, $language['id_lang'])), ENT_COMPAT, 'UTF-8') . '</textarea>
</div>';
}
echo '
</td>
</tr>';
}
echo '
<tr>
<td style="height: 50px; text-align: center;" colspan="3"><input type="submit" name="submitProductFeature" id="submitProductFeature" value="' . $this->l('Save modifications') . '" class="button" /></td>
</tr>';
}
echo '</table>
<hr style="width:100%;" />
<div style="text-align:center;">
<a href="index.php?tab=AdminFeatures&addfeature&token=' . Tools::getAdminToken('AdminFeatures' . (int) Tab::getIdFromClassName('AdminFeatures') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('You will lose all modifications not saved, you may want to save modifications first?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="new_features" title="' . $this->l('Add a new feature') . '" /> ' . $this->l('Add a new feature') . '</a>
</div>';
} else {
echo '<b>' . $this->l('You must save this product before adding features') . '.</b>';
}
}
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:98,代码来源:AdminProducts.php
示例12: productImportOne
//.........这里部分代码省略.........
} else {
$error = true;
}
if ($error) {
$this->warnings[] = sprintf($this->trans('Product #%1$d: the picture (%2$s) cannot be saved.', array(), 'Admin.Parameters.Notification'), $image->id_product, $url);
}
}
}
if (!$validateOnly && isset($product->id_category) && is_array($product->id_category)) {
$product->updateCategories(array_map('intval', $product->id_category));
}
$product->checkDefaultAttributes();
if (!$validateOnly && !$product->cache_default_attribute) {
Product::updateDefaultAttribute($product->id);
}
// Features import
$features = get_object_vars($product);
if (!$validateOnly && isset($features['features']) && !empty($features['features'])) {
foreach (explode($this->multiple_value_separator, $features['features']) as $single_feature) {
if (empty($single_feature)) {
continue;
}
$tab_feature = explode(':', $single_feature);
$feature_name = isset($tab_feature[0]) ? trim($tab_feature[0]) : '';
$feature_value = isset($tab_feature[1]) ? trim($tab_feature[1]) : '';
$position = isset($tab_feature[2]) ? (int) $tab_feature[2] - 1 : false;
$custom = isset($tab_feature[3]) ? (int) $tab_feature[3] : false;
if (!empty($feature_name) && !empty($feature_value)) {
$id_feature = (int) Feature::addFeatureImport($feature_name, $position);
$id_product = null;
if ($force_ids || $match_ref) {
$id_product = (int) $product->id;
}
$id_feature_value = (int) FeatureValue::addFeatureValueImport($id_feature, $feature_value, $id_product, $id_lang, $custom);
Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
}
}
}
// clean feature positions to avoid conflict
Feature::cleanPositions();
// set advanced stock managment
if (!$validateOnly && isset($product->advanced_stock_management)) {
if ($product->advanced_stock_management != 1 && $product->advanced_stock_management != 0) {
$this->warnings[] = sprintf($this->trans('Advanced stock management has incorrect value. Not set for product %1$s ', array(), 'Admin.Parameters.Notification'), $product->name[$default_language_id]);
} elseif (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management == 1) {
$this->warnings[] = sprintf($this->trans('Advanced stock management is not enabled, cannot enable on product %1$s ', array(), 'Admin.Parameters.Notification'), $product->name[$default_language_id]);
} elseif ($update_advanced_stock_management_value) {
$product->setAdvancedStockManagement($product->advanced_stock_management);
}
// automaticly disable depends on stock, if a_s_m set to disabled
if (StockAvailable::dependsOnStock($product->id) == 1 && $product->advanced_stock_management == 0) {
StockAvailable::setProductDependsOnStock($product->id, 0);
}
}
// Check if warehouse exists
if (isset($product->warehouse) && $product->warehouse) {
if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
$this->warnings[] = sprintf($this->trans('Advanced stock management is not enabled, warehouse not set on product %1$s ', array(), 'Admin.Parameters.Notification'), $product->name[$default_language_id]);
} elseif (!$validateOnly) {
if (Warehouse::exists($product->warehouse)) {
// Get already associated warehouses
$associated_warehouses_collection = WarehouseProductLocation::getCollection($product->id);
// Delete any entry in warehouse for this product
foreach ($associated_warehouses_collection as $awc) {
$awc->delete();
}
开发者ID:M03G,项目名称:PrestaShop,代码行数:67,代码来源:AdminImportController.php
示例13: processSave
/**
* Call the right method for creating or updating object
*
* @return mixed
*/
public function processSave()
{
if ($this->table == 'feature') {
$id_feature = (int) Tools::getValue('id_feature');
// Adding last position to the feature if not exist
if ($id_feature <= 0) {
$sql = 'SELECT `position`+1
FROM `' . _DB_PREFIX_ . 'feature`
ORDER BY position DESC';
// set the position of the new feature in $_POST for postProcess() method
$_POST['position'] = DB::getInstance()->getValue($sql);
}
// clean \n\r characters
foreach ($_POST as $key => $value) {
if (preg_match('/^name_/Ui', $key)) {
$_POST[$key] = str_replace('\\n', '', str_replace('\\r', '', $value));
}
}
//by webkul to save image of feature with feature name
$obj_feature = parent::processSave();
$feature_values = FeatureValue::getFeatureValuesWithLang(1, $obj_feature->id);
if ($feature_values) {
$obj_feature_value = new FeatureValue($feature_values[0]['id_feature_value']);
} else {
$obj_feature_value = new FeatureValue();
}
//validate feature image
if (isset($_FILES['logo'])) {
$this->validAddFeatureImage($_FILES['logo']);
}
$img_path = _PS_IMG_DIR_ . 'rf/' . $obj_feature->id . '.png';
if (isset($_FILES['logo'])) {
$current_file = _PS_TMP_IMG_DIR_ . 'feature_mini_' . $obj_feature->id . '_' . $this->context->shop->id . '.png';
if (file_exists($current_file)) {
unlink($current_file);
}
$this->uploadFeatureImage($_FILES['logo'], $img_path);
}
$obj_feature_value->id_feature = $obj_feature->id;
foreach (Language::getLanguages(true) as $lang) {
$obj_feature_value->value[$lang['id_lang']] = $obj_feature->id . '.png';
}
$obj_feature_value->save();
}
return $obj_feature;
}
开发者ID:Rohit-jn,项目名称:hotelcommerce,代码行数:51,代码来源:AdminFeaturesController.php
示例14: FeatureValue
<?php
if (Tools::G('id_feature') > 0) {
$id_feature = Tools::G('id_feature');
}
if (Tools::P('saveFeatureValue') == 'add' && Tools::P('id_feature') > 0) {
$featureV = new FeatureValue();
$featureV->copyFromPost();
$featureV->add();
if (is_array($featureV->_errors) and count($featureV->_errors) > 0) {
$errors = $featureV->_errors;
} else {
$_GET['id'] = $featureV->id;
UIAdminAlerts::conf('商品特征值已添加');
}
$id_feature = Tools::P('id_feature');
}
if (isset($_GET['id'])) {
$id = (int) $_GET['id'];
$obj = new FeatureValue($id);
$id_feature = $obj->id_feature;
}
if (Tools::P('saveFeatureValue') == '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('商品特征值已更新');
开发者ID:yiuked,项目名称:tmcart,代码行数:31,代码来源:feature_value_edit.php
示例15: initFormFeatures
public function initFormFeatures($obj)
{
$data = $this->createTemplate($this->tpl_form);
if (!Feature::isFeatureActive()) {
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:') . ' <a href="index.php?tab=AdminPerformance&token=' . Tools::getAdminTokenLite('AdminPerformance') . '#featuresDetachables">' . $this->l('Performances') . '</a>');
} else {
if ($obj->id) {
if ($this->product_exists_in_shop) {
$features = Feature::getFeatures($this->context->language->id);
foreach ($features as $k => $tab_features) {
$features[$k]['current_item'] = false;
$features[$k]['val'] = array();
$custom = true;
foreach ($obj->getFeatures() as $tab_products) {
if ($tab_products['id_feature'] == $tab_features['id_feature']) {
$features[$k]['current_item'] = $tab_products['id_feature_value'];
}
}
$features[$k]['featureValues'] = FeatureValue::getFeatureValuesWithLang($this->context->language->id, (int) $tab_features['id_feature']);
if (count($features[$k]['featureValues'])) {
foreach ($features[$k]['featureValues'] as $value) {
if ($features[$k]['current_item'] == $value['id_feature_value']) {
$custom = false;
}
}
}
if ($custom) {
$features[$k]['val'] = FeatureValue::getFeatureValueLang($features[$k]['current_item']);
}
}
$data->assign('available_features', $features);
$data->assign('product', $obj);
$data->assign('link', $this->context->link);
$data->assign('languages', $this->_languages);
$data->assign('default_form_language', $this->default_form_language);
} else {
$this->displayWarning($this->l('You must save this product in this shop before adding features.'));
}
} else {
$this->displayWarning($this->l('You must save this product before adding features.'));
}
}
$this->tpl_form_vars['custom_form'] = $data->fetch();
}
开发者ID:jicheng17,项目名称:vipinsg,代码行数:44,代码来源:AdminProductsController.php
示例16: FeatureValue
<?php
if (Tools::G('delete') > 0) {
$feature = new FeatureValue(Tools::G('delete'));
if (Validate::isLoadedObject($feature)) {
$feature->delete();
}
if (is_array($feature->_errors) and count($feature->_errors) > 0) {
$errors = $feature->_errors;
} else {
UIAdminAlerts::conf('商品特征值已删除');
}
} elseif (Tools::isSubmit('delSelected')) {
$select_cat = Tools::P('itemsBox');
$feature = new FeatureValue();
if ($feature->deleteMulti($select_cat)) {
UIAdminAlerts::conf('商品特征值已删除');
}
}
/** 输出错误信息 */
if (isset($errors)) {
UIAdminAlerts::MError($errors);
}
/** 导航 */
$breadcrumb = new UIAdminBreadcrumb();
$breadcrumb->home();
$breadcrumb->add(array('title' => '商品特征', 'href' => 'index.php?rule=feature'));
$breadcrumb->add(array('title' => '商品特征值', 'active'
|
请发表评论