當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。