当前位置: 首页>>代码示例>>PHP>>正文


PHP FeatureValue::add方法代码示例

本文整理汇总了PHP中FeatureValue::add方法的典型用法代码示例。如果您正苦于以下问题:PHP FeatureValue::add方法的具体用法?PHP FeatureValue::add怎么用?PHP FeatureValue::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FeatureValue的用法示例。


在下文中一共展示了FeatureValue::add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: addFeatureValueImport

    public static function addFeatureValueImport($id_feature, $value, $id_product = null, $id_lang = null, $custom = false)
    {
        $id_feature_value = false;
        if (!is_null($id_product) && $id_product) {
            $id_feature_value = Db::getInstance()->getValue('
				SELECT fp.`id_feature_value`
				FROM ' . _DB_PREFIX_ . 'feature_product fp
				INNER JOIN ' . _DB_PREFIX_ . 'feature_value fv USING (`id_feature_value`)
				WHERE fp.`id_feature` = ' . (int) $id_feature . '
				AND fv.`custom` = ' . (int) $custom . '
				AND fp.`id_product` = ' . (int) $id_product);
            if ($custom && $id_feature_value && !is_null($id_lang) && $id_lang) {
                Db::getInstance()->execute('
				UPDATE ' . _DB_PREFIX_ . 'feature_value_lang
				SET `value` = \'' . pSQL($value) . '\'
				WHERE `id_feature_value` = ' . (int) $id_feature_value . '
				AND `value` != \'' . pSQL($value) . '\'
				AND `id_lang` = ' . (int) $id_lang);
            }
        }
        if (!$custom) {
            $id_feature_value = Db::getInstance()->getValue('
				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` AND fvl.`id_lang` = ' . (int) $id_lang . ')
				WHERE `value` = \'' . pSQL($value) . '\'
				AND fv.`id_feature` = ' . (int) $id_feature . '
				AND fv.`custom` = 0
				GROUP BY fv.`id_feature_value`');
        }
        if ($id_feature_value) {
            return (int) $id_feature_value;
        }
        // Feature doesn't exist, create it
        $feature_value = new FeatureValue();
        $feature_value->id_feature = (int) $id_feature;
        $feature_value->custom = (bool) $custom;
        $feature_value->value = array_fill_keys(Language::getIDs(false), $value);
        $feature_value->add();
        return (int) $feature_value->id;
    }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:41,代码来源:FeatureValue.php

示例4: 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

示例5: importFeatureValues

 protected function importFeatureValues()
 {
     $this->truncateTables(array('feature_value', 'feature_value_lang'));
     $handle = $this->openCsvFile('feature_values.csv');
     $languages = Language::getLanguages(false);
     for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, ';'); $current_line++) {
         $res = false;
         $fields = $this->filterFields('FeatureValue', $this->feature_value_fields, $line);
         if (!isset($fields['id'])) {
             $feature_value = new FeatureValue($line[0]);
             $feature_value->id = $line[0];
         } else {
             $feature_value = new FeatureValue($fields['id']);
         }
         foreach ($fields as $key => $field) {
             if ($key == 'value') {
                 $feature_value->{$key} = $this->multilFild($field);
             } else {
                 $feature_value->{$key} = $field;
             }
         }
         $feature_value->force_id = true;
         if (!$res) {
             $res = $feature_value->add();
         }
     }
     $this->closeCsvFile($handle);
     return true;
 }
开发者ID:evgrishin,项目名称:se1614,代码行数:29,代码来源:AdminSampleDataInstallImport.php


注:本文中的FeatureValue::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。