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


PHP Search::indexation方法代码示例

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


在下文中一共展示了Search::indexation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: submitAddProduct


//.........这里部分代码省略.........
             if (!Validate::isTagsList($value)) {
                 $this->_errors[] = $this->l('Tags list') . ' (' . $language['name'] . ') ' . $this->l('is invalid');
             }
         }
     }
     if (!sizeof($this->_errors)) {
         $id = (int) Tools::getValue('id_' . $this->table);
         $tagError = true;
         /* Update an existing product */
         if (isset($id) and !empty($id)) {
             $object = new $this->className($id);
             if (Validate::isLoadedObject($object)) {
                 $this->_removeTaxFromEcotax();
                 $this->copyFromPost($object, $this->table);
                 if ($object->update()) {
                     if ($id_reason = (int) Tools::getValue('id_mvt_reason') and (int) Tools::getValue('mvt_quantity') > 0 and $id_reason > 0) {
                         $reason = new StockMvtReason((int) $id_reason);
                         $qty = Tools::getValue('mvt_quantity') * $reason->sign;
                         if (!$object->addStockMvt($qty, (int) $id_reason, NULL, NULL, (int) $cookie->id_employee)) {
                             $this->_errors[] = Tools::displayError('An error occurred while updating qty.');
                         }
                     }
                     $this->updateAccessories($object);
                     $this->updateDownloadProduct($object);
                     if (!$this->updatePackItems($object)) {
                         $this->_errors[] = Tools::displayError('An error occurred while adding products to the pack.');
                     } elseif (!$object->updateCategories($_POST['categoryBox'], true)) {
                         $this->_errors[] = Tools::displayError('An error occurred while linking object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('To categories');
                     } elseif (!$this->updateTags($languages, $object)) {
                         $this->_errors[] = Tools::displayError('An error occurred while adding tags.');
                     } elseif ($id_image = $this->addProductImage($object, Tools::getValue('resizer'))) {
                         $currentIndex .= '&image_updated=' . (int) Tools::getValue('id_image');
                         Hook::updateProduct($object);
                         Search::indexation(false, $object->id);
                         if (Tools::getValue('resizer') == 'man' && isset($id_image) and is_int($id_image) and $id_image) {
                             Tools::redirectAdmin($currentIndex . '&id_product=' . $object->id . '&id_category=' . (!empty($_REQUEST['id_category']) ? $_REQUEST['id_category'] : '1') . '&edit=' . strval(Tools::getValue('productCreated')) . '&id_image=' . $id_image . '&imageresize&toconf=4&submitAddAndStay=' . ((Tools::isSubmit('submitAdd' . $this->table . 'AndStay') or Tools::getValue('productCreated') == 'on') ? 'on' : 'off') . '&token=' . ($token ? $token : $this->token));
                         }
                         // Save and preview
                         if (Tools::isSubmit('submitAddProductAndPreview')) {
                             $preview_url = $link->getProductLink($this->getFieldValue($object, 'id'), $this->getFieldValue($object, 'link_rewrite', (int) $cookie->id_lang), Category::getLinkRewrite($this->getFieldValue($object, 'id_category_default'), (int) $cookie->id_lang));
                             if (!$object->active) {
                                 $admin_dir = dirname($_SERVER['PHP_SELF']);
                                 $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
                                 $token = Tools::encrypt('PreviewProduct' . $object->id);
                                 if (strpos($preview_url, '?') === false) {
                                     $preview_url .= '?';
                                 } else {
                                     $preview_url .= '&';
                                 }
                                 $preview_url .= 'adtoken=' . $token . '&ad=' . $admin_dir;
                             }
                             Tools::redirectAdmin($preview_url);
                         } elseif (Tools::isSubmit('submitAdd' . $this->table . 'AndStay') or $id_image and $id_image !== true) {
                             // Save and stay on same form
                             // Save and stay on same form
                             if (Tools::isSubmit('submitAdd' . $this->table . 'AndStay')) {
                                 Tools::redirectAdmin($currentIndex . '&id_product=' . $object->id . '&id_category=' . (!empty($_REQUEST['id_category']) ? $_REQUEST['id_category'] : '1') . '&addproduct&conf=4&tabs=' . (int) Tools::getValue('tabs') . '&token=' . ($token ? $token : $this->token));
                             }
                         }
                         // Default behavior (save and back)
                         Tools::redirectAdmin($currentIndex . '&id_category=' . (!empty($_REQUEST['id_category']) ? $_REQUEST['id_category'] : '1') . '&conf=4&token=' . ($token ? $token : $this->token) . '&onredirigeici');
                     }
                 } else {
                     $this->_errors[] = Tools::displayError('An error occurred while updating object.') . ' <b>' . $this->table . '</b> (' . Db::getInstance()->getMsgError() . ')';
                 }
             } else {
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:67,代码来源:AdminProducts.php

示例2: setProducts

 public function setProducts($array)
 {
     Db::getInstance()->Execute('DELETE FROM ' . _DB_PREFIX_ . 'product_tag WHERE id_tag = ' . (int) $this->id);
     if (is_array($array)) {
         $array = array_map('intval', $array);
         $result1 = Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'product SET indexed = 0 WHERE id_product IN (' . implode(',', array_map('intval', $array)) . ')');
         $ids = array();
         foreach ($array as $id_product) {
             $ids[] = '(' . (int) $id_product . ',' . (int) $this->id . ')';
         }
         return $result1 && Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'product_tag (id_product, id_tag) VALUES ' . implode(',', $ids)) && Search::indexation(false);
     }
     return $result1;
 }
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:14,代码来源:Tag.php

示例3: processAdd

 /**
  * Object creation
  */
 public function processAdd()
 {
     if (!Tools::getValue('categoryBox') || !in_array(Tools::getValue('id_category'), Tools::getValue('categoryBox'))) {
         $this->errors[] = $this->l('You need to select at least the root category.');
     }
     if (Tools::isSubmit('id_category_default')) {
         $_POST['id_category'] = (int) Tools::getValue('id_category_default');
     }
     /* Checking fields validity */
     $this->validateRules();
     if (!count($this->errors)) {
         $object = new $this->className();
         $this->copyFromPost($object, $this->table);
         $this->beforeAdd($object);
         if (!$object->add()) {
             $this->errors[] = Tools::displayError('An error occurred while creating an object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>';
         } else {
             if (($_POST[$this->identifier] = $object->id) && $this->postImage($object->id) && !count($this->errors) && $this->_redirect) {
                 $parent_id = (int) Tools::getValue('id_parent', 1);
                 $this->afterAdd($object);
                 $this->updateAssoShop($object->id);
                 // Save and stay on same form
                 if (Tools::isSubmit('submitAdd' . $this->table . 'AndStay')) {
                     $this->redirect_after = self::$currentIndex . '&' . $this->identifier . '=' . $object->id . '&conf=3&update' . $this->table . '&token=' . $this->token;
                 }
                 // Save and back to parent
                 if (Tools::isSubmit('submitAdd' . $this->table . 'AndBackToParent')) {
                     $this->redirect_after = self::$currentIndex . '&' . $this->identifier . '=' . $parent_id . '&conf=3&token=' . $this->token;
                 }
                 // Default behavior (save and back)
                 if (empty($this->redirect_after)) {
                     $this->redirect_after = self::$currentIndex . ($parent_id ? '&' . $this->identifier . '=' . $object->id : '') . '&conf=3&token=' . $this->token;
                 }
             }
         }
     }
     $this->errors = array_unique($this->errors);
     if (count($this->errors) > 0) {
         $this->display = 'add';
         return;
     }
     // specific import for stock
     if (isset($import_data['stock_available']) && isset($import_data['product']) && Tools::isSubmit('useImportData')) {
         $id_src_shop = (int) Tools::getValue('importFromShop');
         if ($object->getGroup()->share_stock == false) {
             StockAvailable::copyStockAvailableFromShopToShop($id_src_shop, $object->id);
         }
     }
     $categories = Tools::getValue('categoryBox');
     array_unshift($categories, Configuration::get('PS_ROOT_CATEGORY'));
     Category::updateFromShop($categories, $object->id);
     Search::indexation(true);
     return $object;
 }
开发者ID:gks-stage,项目名称:prestashop,代码行数:57,代码来源:AdminShopController.php

示例4: installFixtures

 /**
  * PROCESS : installFixtures
  * Install fixtures (E.g. demo products)
  */
 public function installFixtures($entity = null, array $data = array())
 {
     $fixtures_path = _PS_INSTALL_FIXTURES_PATH_ . 'fashion/';
     $fixtures_name = 'fashion';
     $zip_file = _PS_ROOT_DIR_ . '/download/fixtures.zip';
     $temp_dir = _PS_ROOT_DIR_ . '/download/fixtures/';
     // Load class (use fixture class if one exists, or use InstallXmlLoader)
     if (file_exists($fixtures_path . '/install.php')) {
         require_once $fixtures_path . '/install.php';
         $class = 'InstallFixtures' . Tools::toCamelCase($fixtures_name);
         if (!class_exists($class, false)) {
             $this->setError($this->translator->trans('Fixtures class "%class%" not found', array('%class%' => $class), 'Install'));
             return false;
         }
         $xml_loader = new $class();
         if (!$xml_loader instanceof InstallXmlLoader) {
             $this->setError($this->translator->trans('"%class%" must be an instance of "InstallXmlLoader"', array('%class%' => $class), 'Install'));
             return false;
         }
     } else {
         $xml_loader = new InstallXmlLoader();
     }
     // Install XML data (data/xml/ folder)
     $xml_loader->setFixturesPath($fixtures_path);
     if (isset($this->xml_loader_ids) && $this->xml_loader_ids) {
         $xml_loader->setIds($this->xml_loader_ids);
     }
     $languages = array();
     foreach (Language::getLanguages(false) as $lang) {
         $languages[$lang['id_lang']] = $lang['iso_code'];
     }
     $xml_loader->setLanguages($languages);
     if ($entity) {
         $xml_loader->populateEntity($entity);
     } else {
         $xml_loader->populateFromXmlFiles();
         Tools::deleteDirectory($temp_dir, true);
         @unlink($zip_file);
     }
     if ($errors = $xml_loader->getErrors()) {
         $this->setError($errors);
         return false;
     }
     // IDS from xmlLoader are stored in order to use them for fixtures
     $this->xml_loader_ids = $xml_loader->getIds();
     unset($xml_loader);
     // Index products in search tables
     Search::indexation(true);
     return true;
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:54,代码来源:install.php

示例5: installFixtures

 /**
  * PROCESS : installFixtures
  * Install fixtures (E.g. demo products)
  */
 public function installFixtures($entity = null, array $data = array())
 {
     $fixtures_path = _PS_INSTALL_FIXTURES_PATH_ . 'apple/';
     $fixtures_name = 'apple';
     $zip_file = _PS_ROOT_DIR_ . '/download/fixtures.zip';
     $temp_dir = _PS_ROOT_DIR_ . '/download/fixtures/';
     // try to download fixtures if no low memory mode
     if ($entity === null) {
         if (Tools::copy('http://api.prestashop.com/fixtures/' . $data['shop_country'] . '/' . $data['shop_activity'] . '/fixtures.zip', $zip_file)) {
             Tools::deleteDirectory($temp_dir, true);
             if (Tools::ZipTest($zip_file)) {
                 if (Tools::ZipExtract($zip_file, $temp_dir)) {
                     $files = scandir($temp_dir);
                     if (count($files)) {
                         foreach ($files as $file) {
                             if (!preg_match('/^\\./', $file) && is_dir($temp_dir . $file . '/')) {
                                 $fixtures_path = $temp_dir . $file . '/';
                                 $fixtures_name = $file;
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
     // Load class (use fixture class if one exists, or use InstallXmlLoader)
     if (file_exists($fixtures_path . '/install.php')) {
         require_once $fixtures_path . '/install.php';
         $class = 'InstallFixtures' . Tools::toCamelCase($fixtures_name);
         if (!class_exists($class, false)) {
             $this->setError($this->language->l('Fixtures class "%s" not found', $class));
             return false;
         }
         $xml_loader = new $class();
         if (!$xml_loader instanceof InstallXmlLoader) {
             $this->setError($this->language->l('"%s" must be an instane of "InstallXmlLoader"', $class));
             return false;
         }
     } else {
         $xml_loader = new InstallXmlLoader();
     }
     // Install XML data (data/xml/ folder)
     $xml_loader->setFixturesPath($fixtures_path);
     if (isset($this->xml_loader_ids) && $this->xml_loader_ids) {
         $xml_loader->setIds($this->xml_loader_ids);
     }
     $languages = array();
     foreach (Language::getLanguages(false) as $lang) {
         $languages[$lang['id_lang']] = $lang['iso_code'];
     }
     $xml_loader->setLanguages($languages);
     if ($entity) {
         $xml_loader->populateEntity($entity);
     } else {
         $xml_loader->populateFromXmlFiles();
         Tools::deleteDirectory($temp_dir, true);
         @unlink($zip_file);
     }
     if ($errors = $xml_loader->getErrors()) {
         $this->setError($errors);
         return false;
     }
     // IDS from xmlLoader are stored in order to use them for fixtures
     $this->xml_loader_ids = $xml_loader->getIds();
     unset($xml_loader);
     // Index products in search tables
     Search::indexation(true);
     return true;
 }
开发者ID:toufikadfab,项目名称:PrestaShop-1.5,代码行数:74,代码来源:install.php

示例6: postProcess


//.........这里部分代码省略.........
         } else {
             if (Tools::isSubmit("submitFeatures")) {
                 $this->processFeatures();
                 if (empty($this->errors)) {
                     self::$smarty->assign("cfmmsg_flag", 1);
                 }
             } else {
                 if (Tools::isSubmit("submitAssociations")) {
                     $this->updateAccessories();
                     $this->object->updateCategories(Tools::getValue("categoryBox"), true);
                     ${${"GLOBALS"}["qiymoeuqk"]} = $this->addNewCategory($this->object->id, intval(Tools::getValue("id_category_default")));
                     ${"GLOBALS"}["xgllsk"] = "newid";
                     $this->object->id_category_default = ${${"GLOBALS"}["qiymoeuqk"]} > 0 ? ${${"GLOBALS"}["xgllsk"]} : intval(Tools::getValue("id_category_default"));
                     if (intval($this->object->id_category_default) <= 0) {
                         $this->errors[] = Tools::displayError("Default category is required");
                         return;
                     }
                     $this->object->save();
                     if (empty($this->errors)) {
                         self::$smarty->assign("cfmmsg_flag", 1);
                     }
                 } else {
                     if (Tools::isSubmit("submitSpecificPrices")) {
                         $this->object->wholesale_price = floatval(Tools::getValue("wholesale_price"));
                         $this->object->price = floatval(Tools::getValue("price"));
                         if (floatval(Tools::getValue("unit_price")) != 0) {
                             $this->object->unit_price = (double) Tools::getValue("unit_price");
                             $this->object->unit_price_ratio = $this->object->price / floatval(Tools::getValue("unit_price"));
                         }
                         $this->object->unity = Tools::getValue("unity");
                         $this->object->on_sale = Tools::getValue("on_sale");
                         $this->object->id_tax_rules_group = Tools::getValue("id_tax_rules_group");
                         $this->object->save();
                         $this->processPriceAddition();
                         $this->processSpecificPricePriorities();
                         if (empty($this->errors)) {
                             self::$smarty->assign("cfmmsg_flag", 1);
                         }
                     } else {
                         if (Tools::isSubmit("submitQuantities")) {
                             $this->copyFromPost($this->object, $this->table);
                             $this->object->save();
                             if (empty($this->errors)) {
                                 self::$smarty->assign("cfmmsg_flag", 1);
                             }
                         } else {
                             if (Tools::isSubmit("submitCombinations")) {
                                 $this->processCombinations();
                                 if (empty($this->errors)) {
                                     self::$smarty->assign("cfmmsg_flag", 1);
                                 }
                             } else {
                                 if (Tools::isSubmit("submitVirtualProduct")) {
                                     $this->object->is_virtual = Tools::getValue("is_virtual_good") == "true" ? 1 : 0;
                                     $this->object->save($this->object);
                                     if ($this->object->is_virtual and intval(Tools::getValue("is_virtual_file"))) {
                                         $this->updateDownloadProduct($this->object);
                                     }
                                     if (empty($this->errors)) {
                                         self::$smarty->assign("cfmmsg_flag", 1);
                                     }
                                 } else {
                                     if (Tools::isSubmit("submitShipping")) {
                                         $this->processShipping();
                                         if (empty($this->errors)) {
                                             self::$smarty->assign("cfmmsg_flag", 1);
                                         }
                                     } else {
                                         if (Tools::isSubmit("submitAddAttachments")) {
                                             $this->processAddAttachments();
                                             if (empty($this->errors)) {
                                                 self::$smarty->assign("cfmmsg_flag", 1);
                                             }
                                         } else {
                                             if (Tools::isSubmit("submitAttachments")) {
                                                 $this->processAttachments();
                                                 $this->object->cache_has_attachments = (bool) Db::getInstance()->getValue("SELECT id_attachment FROM " . _DB_PREFIX_ . "product_attachment WHERE id_product=" . (int) $this->object->id);
                                                 if (empty($this->errors)) {
                                                     self::$smarty->assign("cfmmsg_flag", 1);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     Hook::exec("actionProductUpdate", array("product" => $this->object));
     if (empty($this->errors)) {
         if (Validate::isLoadedObject($this->object) && $this->object->update()) {
             if (in_array($this->object->visibility, array("both", "search")) && Configuration::get("PS_SEARCH_INDEXATION")) {
                 Search::indexation(false, $this->object->id);
             }
         }
     }
 }
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:101,代码来源:sellerproductdetailbase.php

示例7: define

* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <contact@prestashop.com>
*  @copyright  2007-2015 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_ADMIN_DIR_')) {
    define('_PS_ADMIN_DIR_', getcwd());
}
include _PS_ADMIN_DIR_ . '/../config/config.inc.php';
Context::getContext()->shop->setContext(Shop::CONTEXT_ALL);
if (substr(_COOKIE_KEY_, 34, 8) != Tools::getValue('token')) {
    die;
}
ini_set('max_execution_time', 7200);
Search::indexation(Tools::getValue('full'));
if (Tools::getValue('redirect')) {
    Tools::redirectAdmin($_SERVER['HTTP_REFERER'] . '&conf=4');
}
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:31,代码来源:searchcron.php

示例8: updateWs

 public function updateWs($nullValues = false)
 {
     $success = parent::update($nullValues);
     if ($success) {
         Search::indexation(false, $this->id);
     }
     return $success;
 }
开发者ID:greench,项目名称:prestashop,代码行数:8,代码来源:Product.php

示例9: productImport


//.........这里部分代码省略.........
                        $product->tags = AdminImportController::createMultiLangField($product->tags);
                        foreach ($product->tags as $key => $tags) {
                            $is_tag_added = Tag::addTags($key, $product->id, $tags, $this->multiple_value_separator);
                            if (!$is_tag_added) {
                                $this->addProductWarning($info['name'], $product->id, $this->l('Tags list is invalid'));
                                break;
                            }
                        }
                    } else {
                        foreach ($product->tags as $key => $tags) {
                            $str = '';
                            foreach ($tags as $one_tag) {
                                $str .= $one_tag . $this->multiple_value_separator;
                            }
                            $str = rtrim($str, $this->multiple_value_separator);
                            $is_tag_added = Tag::addTags($key, $product->id, $str, $this->multiple_value_separator);
                            if (!$is_tag_added) {
                                $this->addProductWarning($info['name'], $product->id, 'Invalid tag(s) (' . $str . ')');
                                break;
                            }
                        }
                    }
                }
                //delete existing images if "delete_existing_images" is set to 1
                if (isset($product->delete_existing_images)) {
                    if ((bool) $product->delete_existing_images) {
                        $product->deleteImages();
                    } else {
                        if (isset($product->image) && is_array($product->image) && count($product->image)) {
                            $product->deleteImages();
                        }
                    }
                }
                if (isset($product->image) && is_array($product->image) && count($product->image)) {
                    $product_has_images = (bool) Image::getImages($this->context->language->id, (int) $product->id);
                    foreach ($product->image as $key => $url) {
                        $url = trim($url);
                        $error = false;
                        if (!empty($url)) {
                            $url = str_replace(' ', '%20', $url);
                            $image = new Image();
                            $image->id_product = (int) $product->id;
                            $image->position = Image::getHighestPosition($product->id) + 1;
                            $image->cover = !$key && !$product_has_images ? true : false;
                            // file_exists doesn't work with HTTP protocol
                            if (@fopen($url, 'r') == false) {
                                $error = true;
                            } else {
                                if (($field_error = $image->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $image->add()) {
                                    // associate image to selected shops
                                    $image->associateTo($shops);
                                    if (!AdminImportController::copyImg($product->id, $image->id, $url)) {
                                        $image->delete();
                                        $this->warnings[] = sprintf(Tools::displayError('Error copying image: %s'), $url);
                                    }
                                } else {
                                    $error = true;
                                }
                            }
                        } else {
                            $error = true;
                        }
                        if ($error) {
                            $this->warnings[] = sprintf(Tools::displayError('Product n°%1$d: the picture cannot be saved: %2$s'), $image->id_product, $url);
                        }
                    }
                }
                if (isset($product->id_category)) {
                    $product->updateCategories(array_map('intval', $product->id_category));
                }
                // Features import
                $features = get_object_vars($product);
                if (isset($features['features']) && !empty($features['features'])) {
                    foreach (explode($this->multiple_value_separator, $features['features']) as $single_feature) {
                        $tab_feature = explode(':', $single_feature);
                        $feature_name = trim($tab_feature[0]);
                        $feature_value = trim($tab_feature[1]);
                        $position = isset($tab_feature[2]) ? $tab_feature[2] : false;
                        $id_feature = Feature::addFeatureImport($feature_name, $position);
                        $id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $feature_value);
                        Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
                    }
                }
                // clean feature positions to avoid conflict
                Feature::cleanPositions();
            }
            // stock available
            if (Shop::isFeatureActive()) {
                foreach ($shops as $shop) {
                    StockAvailable::setQuantity((int) $product->id, 0, $product->quantity, (int) $shop);
                }
            } else {
                StockAvailable::setQuantity((int) $product->id, 0, $product->quantity, $this->context->shop->id);
            }
        }
        if (Configuration::get('PS_SEARCH_INDEXATION')) {
            Search::indexation(true);
        }
        $this->closeCsvFile($handle);
    }
开发者ID:jicheng17,项目名称:pengwine,代码行数:101,代码来源:AdminImportController.php

示例10: execImport

 public static function execImport($pdt)
 {
     if ($pdt->id_product > 0) {
         $product = new Product($pdt->id_product);
     } else {
         $product = new Product();
     }
     if (version_compare(_PS_VERSION_, '1.5', '>=')) {
         foreach (Product::$definition['fields'] as $field => $value) {
             if (isset($pdt->{$field})) {
                 if (is_object($pdt->{$field})) {
                     $fields = array();
                     foreach ($pdt->{$field} as $key => $value) {
                         $fields[$key] = $value;
                     }
                     $product->{$field} = $fields;
                 } else {
                     $product->{$field} = $pdt->{$field};
                 }
             }
         }
     } else {
         $product->id_manufacturer = $pdt->id_manufacturer;
         $product->id_supplier = $pdt->id_supplier;
         if ($pdt->reference) {
             $product->reference = $pdt->reference;
         }
         $product->supplier_reference = $pdt->supplier_reference;
         $product->weight = $pdt->weight;
         $product->id_category_default = $pdt->id_category_default;
         if ($pdt->id_tax_rules_group) {
             $product->id_tax_rules_group = $pdt->id_tax_rules_group;
         }
         if ($pdt->price) {
             $product->price = $pdt->price;
         }
         if ($pdt->wholesale_price) {
             $product->wholesale_price = $pdt->wholesale_price;
         }
         if ($pdt->active) {
             $product->active = $pdt->active;
         }
         if ($pdt->date_add) {
             $product->date_add = $pdt->date_add;
         }
         $product->date_upd = $pdt->date_upd;
         if ($pdt->link_rewrite) {
             foreach ($pdt->link_rewrite as $key => $value) {
                 $product->link_rewrite[$key] = $value;
             }
         }
         if ($pdt->name) {
             foreach ($pdt->name as $key => $value) {
                 $product->name[$key] = $value;
             }
         }
         if ($pdt->description) {
             foreach ($pdt->description as $key => $value) {
                 $product->description[$key] = $value;
             }
         }
         if ($pdt->description_short) {
             foreach ($pdt->description_short as $key => $value) {
                 $product->description_short[$key] = $value;
             }
         }
         if ($pdt->ean13) {
             $product->ean13 = $pdt->ean13;
         }
     }
     if ($pdt->upd_index == 1) {
         $product->indexed = 1;
     }
     if (version_compare(_PS_VERSION_, '1.5', '>=')) {
         $product->id_shop_list[] = $pdt->shop;
     }
     $product->id_category[] = $pdt->categories;
     $product->id_category[] = $pdt->sscategories;
     if ($pdt->id_product) {
         $category_data = Product::getProductCategories((int) $product->id);
         foreach ($category_data as $tmp) {
             $product->id_category[] = $tmp;
         }
     }
     $product->id_category = array_unique($product->id_category);
     $product->save();
     if ($pdt->upd_img == 1 || !$pdt->id_product) {
         self::execImages($pdt, $product);
         self::cleanUploadedImages($pdt, $product);
     }
     if (version_compare(_PS_VERSION_, '1.5', '>=')) {
         if (!$pdt->id_product) {
             self::insertSupplierRef($product->id, 0, $pdt->id_supplier, $pdt->supplier_reference);
         }
     }
     if ($pdt->upd_index == 1) {
         Search::indexation(false, $pdt->id_product);
     }
     $product->updateCategories(array_map('intval', $product->id_category));
     return $product->id;
//.........这里部分代码省略.........
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:101,代码来源:importProduct.class.php

示例11: importProducts


//.........这里部分代码省略.........
             $product->unity = $line[28];
         }
         if (trim($line[29])) {
             $product->unit_price = $line[29];
         }
         foreach ($languages as $lang) {
             $product->description_short[$lang['id_lang']] = $line[30];
             $product->description[$lang['id_lang']] = $line[31];
         }
         if ($line[32]) {
             foreach ($languages as $lang) {
                 Tag::addTags($lang['id_lang'], $product->id, $line[32]);
             }
         }
         foreach ($languages as $lang) {
             $product->meta_title[$lang['id_lang']] = $line[33];
             $product->meta_keywords[$lang['id_lang']] = $line[34];
             $product->meta_description[$lang['id_lang']] = $line[35];
             $product->link_rewrite[$lang['id_lang']] = $line[36];
             $product->available_now[$lang['id_lang']] = $line[37];
             $product->available_later[$lang['id_lang']] = $line[38];
         }
         $product->available_for_order = $line[39];
         $product->available_date = $line[40];
         $product->date_add = $line[41];
         $product->show_price = $line[42];
         // Features import
         $features = explode(',', $line[45]);
         if ($features) {
             foreach ($features as $feature) {
                 $value = explode(':', $feature);
                 if ($value[0] && $value[1]) {
                     Product::addFeatureProductImport((int) $product->id, (int) $value[0], (int) $value[1]);
                     SpecificPriceRule::applyAllRules(array((int) $product->id));
                 }
             }
         }
         $product->online_only = trim($line[46]) ? $line[46] : 0;
         $product->condition = $line[47];
         $product->customizable = trim($line[48]) ? $line[48] : 0;
         $product->uploadable_files = trim($line[49]) ? $line[49] : 0;
         $product->text_fields = trim($line[50]) ? $line[50] : 0;
         if ($product->getType() == Product::PTYPE_VIRTUAL) {
             StockAvailable::setProductOutOfStock((int) $product->id, 1);
         } else {
             StockAvailable::setProductOutOfStock((int) $product->id, (int) $line[51]);
         }
         $product->id_shop_default = $line[52];
         // add product accessories
         if ($line[56]) {
             $accessories = explode(',', $line[56]);
             foreach ($accessories as $accessory) {
                 $a[]['id'] = $accessory;
             }
             $product->setWsAccessories($a);
         }
         // add product carriers
         if ($line[57]) {
             $carriers = explode(',', $line[57]);
             $product->setCarriers($carriers);
         }
         // add costomisation fields
         if (!Tools::isEmpty($line[58]) && class_exists('CustomizationField')) {
             $customisation_fields_ids = explode(',', $line[58]);
             foreach ($customisation_fields_ids as $customisation_field) {
                 $result = false;
                 $customisation_data = explode(':', $customisation_field);
                 $cf = new CustomizationField();
                 $cf->id_product = $product->id;
                 $cf->type = $customisation_data[1];
                 $cf->required = $customisation_data[2];
                 foreach ($languages as $lang) {
                     $cf->name[$lang['id_lang']] = $customisation_data[3] ? $customisation_data[3] : ' ';
                 }
                 $cf->force_id = 1;
                 if (!$result) {
                     $result = $cf->add();
                 }
             }
         }
         // add attachments
         if ($line[59]) {
             $attachments = explode(',', $line[59]);
             if (isset($attachments) && count($attachments)) {
                 Attachment::attachToProduct($product->id, $attachments);
             }
         }
         if ($line[60]) {
             $product->date_upd = $line[60];
         }
         $product->price = $line[61];
         $product->force_id = 1;
         if (!$res) {
             $res = $product->add();
         }
     }
     $this->closeCsvFile($handle);
     Search::indexation(true);
     return true;
 }
开发者ID:evgrishin,项目名称:se1614,代码行数:101,代码来源:AdminSampleDataInstallImport.php

示例12: define

* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <contact@prestashop.com>
*  @copyright  2007-2014 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_ADMIN_DIR_')) {
    define('_PS_ADMIN_DIR_', getcwd());
}
include _PS_ADMIN_DIR_ . '/../config/config.inc.php';
Context::getContext()->shop->setContext(Shop::CONTEXT_ALL);
if (substr(_COOKIE_KEY_, 34, 8) != Tools::getValue('token')) {
    die;
}
ini_set('max_execution_time', 7200);
$id_product = 16623;
Search::indexation(false, $id_product);
if (Tools::getValue('redirect')) {
    Tools::redirectAdmin($_SERVER['HTTP_REFERER'] . '&conf=4');
}
开发者ID:Gelikon,项目名称:gelikon,代码行数:31,代码来源:searchindexationone.php

示例13: updateWs

 public function updateWs($null_values = false)
 {
     $success = parent::update($null_values);
     if ($success && Configuration::get('PS_SEARCH_INDEXATION')) {
         Search::indexation(false, $this->id);
     }
     return $success;
 }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:8,代码来源:Product.php

示例14: processDuplicate

 public function processDuplicate()
 {
     if (!Module::isInstalled('agilemultipleseller')) {
         parent::processDuplicate();
     } else {
         if (Validate::isLoadedObject($product = new Product((int) Tools::getValue('id_product')))) {
             $id_product_old = $product->id;
             if (empty($product->price) && Shop::getContext() == Shop::CONTEXT_GROUP) {
                 $shops = ShopGroup::getShopsFromGroup(Shop::getContextShopGroupID());
                 foreach ($shops as $shop) {
                     if ($product->isAssociatedToShop($shop['id_shop'])) {
                         $product_price = new Product($id_product_old, false, null, $shop['id_shop']);
                         $product->price = $product_price->price;
                     }
                 }
             }
             unset($product->id);
             unset($product->id_product);
             $product->indexed = 0;
             $product->active = 0;
             if ($product->add() && Category::duplicateProductCategories($id_product_old, $product->id) && ($combination_images = Product::duplicateAttributes($id_product_old, $product->id)) !== false && GroupReduction::duplicateReduction($id_product_old, $product->id) && Product::duplicateAccessories($id_product_old, $product->id) && Product::duplicateFeatures($id_product_old, $product->id) && Product::duplicateSpecificPrices($id_product_old, $product->id) && Pack::duplicate($id_product_old, $product->id) && Product::duplicateCustomizationFields($id_product_old, $product->id) && Product::duplicateTags($id_product_old, $product->id) && Product::duplicateDownload($id_product_old, $product->id)) {
                 if ($product->hasAttributes()) {
                     Product::updateDefaultAttribute($product->id);
                 }
                 AgileSellerManager::assignObjectOwner('product', $product->id, AgileSellerManager::getObjectOwnerID('product', $id_product_old));
                 if (!Tools::getValue('noimage') && !Image::duplicateProductImages($id_product_old, $product->id, $combination_images)) {
                     $this->errors[] = Tools::displayError('An error occurred while copying images.');
                 } else {
                     Hook::exec('actionProductAdd', array('product' => $product));
                     if (in_array($product->visibility, array('both', 'search')) && Configuration::get('PS_SEARCH_INDEXATION')) {
                         Search::indexation(false, $product->id);
                     }
                     $this->redirect_after = self::$currentIndex . (Tools::getIsset('id_category') ? '&id_category=' . (int) Tools::getValue('id_category') : '') . '&conf=19&token=' . $this->token;
                 }
             } else {
                 $this->errors[] = Tools::displayError('An error occurred while creating an object.');
             }
         }
     }
 }
开发者ID:evilscripts,项目名称:gy,代码行数:40,代码来源:AdminProductsController.php

示例15: installFixtures

 /**
  * PROCESS : installFixtures
  * Install fixtures (E.g. demo products)
  */
 public function installFixtures($entity = null)
 {
     // Load class (use fixture class if one exists, or use InstallXmlLoader)
     if (file_exists(_PS_INSTALL_FIXTURES_PATH_ . 'apple/install.php')) {
         require_once _PS_INSTALL_FIXTURES_PATH_ . 'apple/install.php';
         $class = 'InstallFixtures' . Tools::toCamelCase('apple');
         if (!class_exists($class, false)) {
             $this->setError($this->language->l('Fixtures class "%s" not found', $class));
             return false;
         }
         $xml_loader = new $class();
         if (!$xml_loader instanceof InstallXmlLoader) {
             $this->setError($this->language->l('"%s" must be an instane of "InstallXmlLoader"', $class));
             return false;
         }
     } else {
         $xml_loader = new InstallXmlLoader();
     }
     // Install XML data (data/xml/ folder)
     $xml_loader->setFixturesPath();
     if (isset($this->xml_loader_ids) && $this->xml_loader_ids) {
         $xml_loader->setIds($this->xml_loader_ids);
     }
     $languages = array();
     foreach (Language::getLanguages(false) as $lang) {
         $languages[$lang['id_lang']] = $lang['iso_code'];
     }
     $xml_loader->setLanguages($languages);
     if ($entity) {
         $xml_loader->populateEntity($entity);
     } else {
         $xml_loader->populateFromXmlFiles();
     }
     if ($errors = $xml_loader->getErrors()) {
         $this->setError($errors);
         return false;
     }
     // IDS from xmlLoader are stored in order to use them for fixtures
     $this->xml_loader_ids = $xml_loader->getIds();
     unset($xml_loader);
     // Index products in search tables
     Search::indexation(true);
     return true;
 }
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:48,代码来源:install.php


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