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


PHP option::save方法代码示例

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


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

示例1: update

 public function update($params = array())
 {
     global $db;
     //Get the product
     $product = $db->selectObject('product', 'id =' . $params['id']);
     //Get product files
     $product->expFile = $this->getProductFiles($params['id']);
     // eDebug($product, true);
     $tab_loaded = $params['tab_loaded'];
     //check if we're saving a newly copied product and if we create children also
     $originalId = isset($params['original_id']) && isset($params['copy_children']) ? $params['original_id'] : 0;
     $originalModel = isset($params['original_model']) && isset($params['copy_children']) ? $params['original_model'] : 0;
     if (!empty($product->parent_id)) {
         $product->sef_url = '';
     }
     //if child, set sef_url to nada
     //Tabs with not directly being saved in the product table and need some special operations
     $tab_exceptions = array('categories', 'options', 'related', 'userinput', 'extrafields', 'model', 'notes');
     foreach ($tab_loaded as $tab_key => $tab_item) {
         if (!in_array($tab_key, $tab_exceptions)) {
             foreach ($params[$tab_key] as $key => $item) {
                 $product->{$key} = $item;
             }
         }
     }
     if (isset($tab_loaded['images'])) {
         $product->expFile = $params['expFile'];
     }
     if ($params['shipping']['required_shipping_calculator_id'] > 0) {
         $product->required_shipping_method = $params['required_shipping_methods'][$params['shipping']['required_shipping_calculator_id']];
     }
     if (isset($tab_loaded['categories'])) {
         $this->saveCategories($params['storeCategory'], null, $params['id'], $this->classname);
     }
     if (isset($tab_loaded['options'])) {
         //Option Group Tab
         if (!empty($params['optiongroups'])) {
             foreach ($params['optiongroups'] as $title => $group) {
                 if (isset($this->params['original_id']) && $params['original_id'] != 0) {
                     $group['id'] = '';
                 }
                 //for copying products
                 $optiongroup = new optiongroup($group);
                 $optiongroup->product_id = $product->id;
                 $optiongroup->save();
                 foreach ($params['optiongroups'][$title]['options'] as $opt_title => $opt) {
                     if (isset($params['original_id']) && $params['original_id'] != 0) {
                         $opt['id'] = '';
                     }
                     //for copying products
                     $opt['product_id'] = $product->id;
                     $opt['is_default'] = false;
                     $opt['title'] = $opt_title;
                     $opt['optiongroup_id'] = $optiongroup->id;
                     if (isset($params['defaults'][$title]) && $params['defaults'][$title] == $opt['title']) {
                         $opt['is_default'] = true;
                     }
                     $option = new option($opt);
                     $option->save();
                 }
             }
         }
     }
     if (isset($tab_loaded['related'])) {
         //Related Products Tab
         if (!empty($tab_loaded['related']) && (empty($originalId) || !empty($params['copy_related']))) {
             $relprods = $db->selectObjects('crosssellItem_product', "product_id=" . $product->id);
             $db->delete('crosssellItem_product', 'product_id=' . $product->id);
             foreach ($params['relatedProducts'] as $key => $prodid) {
                 $ptype = new product($prodid);
                 $tmp->product_id = $product->id;
                 $tmp->crosssellItem_id = $prodid;
                 $tmp->product_type = $ptype->product_type;
                 $db->insertObject($tmp, 'crosssellItem_product');
                 if (isset($params['relateBothWays'][$prodid])) {
                     $tmp->crosssellItem_id = $product->id;
                     $tmp->product_id = $prodid;
                     $tmp->product_type = $ptype->product_type;
                     $db->insertObject($tmp, 'crosssellItem_product');
                 }
             }
         }
     }
     if (isset($tab_loaded['userinput'])) {
         //User Input fields Tab
         if (isset($params['user_input_use']) && is_array($params['user_input_use'])) {
             foreach ($params['user_input_use'] as $ukey => $ufield) {
                 $user_input_fields[] = array('use' => $params['user_input_use'][$ukey], 'name' => $params['user_input_name'][$ukey], 'is_required' => $params['user_input_is_required'][$ukey], 'min_length' => $params['user_input_min_length'][$ukey], 'max_length' => $params['user_input_max_length'][$ukey], 'description' => $params['user_input_description'][$ukey]);
             }
             $product->user_input_fields = serialize($user_input_fields);
         } else {
             $product->user_input_fields = serialize(array());
         }
     }
     if (isset($tab_loaded['extrafields'])) {
         //Extra Field Tab
         foreach ($params['extra_fields_name'] as $xkey => $xfield) {
             if (!empty($xfield)) {
                 $extra_fields[] = array('name' => $xfield, 'value' => $params['extra_fields_value'][$xkey]);
             }
//.........这里部分代码省略.........
开发者ID:notzen,项目名称:exponent-cms,代码行数:101,代码来源:product.php


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