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


PHP VirtueMartModelCustomfields::storeProductCustomfields方法代码示例

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


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

示例1: store

 /**
  * Store a product
  *
  * @author Max Milbers
  * @param $product given as reference
  * @param bool $isChild Means not that the product is child or not. It means if the product should be threated as child
  * @return bool
  */
 public function store(&$product, $isChild = FALSE)
 {
     JRequest::checkToken() or jexit('Invalid Token');
     if ($product) {
         $data = (array) $product;
     }
     if (!class_exists('Permissions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
     }
     $perm = Permissions::getInstance();
     $superVendor = $perm->isSuperVendor();
     if (empty($superVendor)) {
         vmError('You are not a vendor or administrator, storing of product cancelled');
         return FALSE;
     }
     if (isset($data['intnotes'])) {
         $data['intnotes'] = trim($data['intnotes']);
     }
     // Setup some place holders
     $product_data = $this->getTable('products');
     if (!empty($data['virtuemart_product_id'])) {
         $product_data->load($data['virtuemart_product_id']);
     }
     //Set the decimals like product packaging
     //$decimals = array('product_length','product_width','product_height','product_weight','product_packaging');
     foreach ($this->decimals as $decimal) {
         if (array_key_exists($decimal, $data)) {
             if (!empty($data[$decimal])) {
                 $data[$decimal] = str_replace(',', '.', $data[$decimal]);
             } else {
                 $data[$decimal] = null;
                 $product_data->{$decimal} = null;
                 //vmdebug('Store product, set $decimal '.$decimal.' = null');
             }
         }
     }
     //with the true, we do preloading and preserve so old values note by Max Milbers
     //	$product_data->bindChecknStore ($data, $isChild);
     //We prevent with this line, that someone is storing a product as its own parent
     if (!empty($product_data->product_parent_id) and $product_data->product_parent_id == $data['virtuemart_product_id']) {
         $product_data->product_parent_id = 0;
     }
     $stored = $product_data->bindChecknStore($data, false);
     $errors = $product_data->getErrors();
     if (!$stored or count($errors) > 0) {
         foreach ($errors as $error) {
             vmError('Product store ' . $error);
         }
         if (!$stored) {
             vmError('You are not an administrator or the correct vendor, storing of product cancelled');
         }
         return FALSE;
     }
     $this->_id = $data['virtuemart_product_id'] = (int) $product_data->virtuemart_product_id;
     if (empty($this->_id)) {
         vmError('Product not stored, no id');
         return FALSE;
     }
     //We may need to change this, the reason it is not in the other list of commands for parents
     if (!$isChild) {
         if (!empty($data['save_customfields'])) {
             if (!class_exists('VirtueMartModelCustomfields')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'customfields.php';
             }
             VirtueMartModelCustomfields::storeProductCustomfields('product', $data, $product_data->virtuemart_product_id);
         }
     }
     // Get old IDS
     $old_price_ids = $this->loadProductPrices($this->_id, 0, 0, false);
     //vmdebug('$old_price_ids ',$old_price_ids);
     if (isset($data['mprices']['product_price']) and count($data['mprices']['product_price']) > 0) {
         foreach ($data['mprices']['product_price'] as $k => $product_price) {
             $pricesToStore = array();
             $pricesToStore['virtuemart_product_id'] = $this->_id;
             $pricesToStore['virtuemart_product_price_id'] = (int) $data['mprices']['virtuemart_product_price_id'][$k];
             if (!$isChild) {
                 //$pricesToStore['basePrice'] = $data['mprices']['basePrice'][$k];
                 $pricesToStore['product_override_price'] = $data['mprices']['product_override_price'][$k];
                 $pricesToStore['override'] = (int) $data['mprices']['override'][$k];
                 $pricesToStore['virtuemart_shoppergroup_id'] = (int) $data['mprices']['virtuemart_shoppergroup_id'][$k];
                 $pricesToStore['product_tax_id'] = (int) $data['mprices']['product_tax_id'][$k];
                 $pricesToStore['product_discount_id'] = (int) $data['mprices']['product_discount_id'][$k];
                 $pricesToStore['product_currency'] = (int) $data['mprices']['product_currency'][$k];
                 $pricesToStore['product_price_publish_up'] = $data['mprices']['product_price_publish_up'][$k];
                 $pricesToStore['product_price_publish_down'] = $data['mprices']['product_price_publish_down'][$k];
                 $pricesToStore['price_quantity_start'] = (int) $data['mprices']['price_quantity_start'][$k];
                 $pricesToStore['price_quantity_end'] = (int) $data['mprices']['price_quantity_end'][$k];
             }
             if (!$isChild and isset($data['mprices']['use_desired_price'][$k]) and $data['mprices']['use_desired_price'][$k] == "1") {
                 if (!class_exists('calculationHelper')) {
                     require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
                 }
//.........这里部分代码省略.........
开发者ID:aldegtyarev,项目名称:stelsvelo,代码行数:101,代码来源:product.php

示例2: store

 /**
  * Store a product
  *
  * @author RolandD
  * @author Max Milbers
  * @access public
  */
 public function store(&$product, $isChild = FALSE)
 {
     JRequest::checkToken() or jexit('Invalid Token');
     if ($product) {
         $data = (array) $product;
     }
     if (!class_exists('Permissions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
     }
     $perm = Permissions::getInstance();
     $superVendor = $perm->isSuperVendor();
     if (empty($superVendor)) {
         vmError('You are not a vendor or administrator, storing of product cancelled');
         return FALSE;
     }
     if (isset($data['intnotes'])) {
         $data['intnotes'] = trim($data['intnotes']);
     }
     // Setup some place holders
     $product_data = $this->getTable('products');
     //Set the product packaging
     if (array_key_exists('product_packaging', $data)) {
         $data['product_packaging'] = str_replace(',', '.', $data['product_packaging']);
     }
     //with the true, we do preloading and preserve so old values note by Max Milbers
     //	$product_data->bindChecknStore ($data, $isChild);
     $stored = $product_data->bindChecknStore($data, TRUE);
     $errors = $product_data->getErrors();
     if (!$stored or count($errors) > 0) {
         foreach ($errors as $error) {
             vmError('Product store ' . $error);
         }
         if (!$stored) {
             vmError('You are not an administrator or the correct vendor, storing of product cancelled');
         }
         return FALSE;
     }
     $this->_id = $data['virtuemart_product_id'] = $product_data->virtuemart_product_id;
     if (empty($this->_id)) {
         vmError('Product not stored, no id');
         return FALSE;
     }
     //We may need to change this, the reason it is not in the other list of commands for parents
     if (!$isChild) {
         if (!empty($data['save_customfields'])) {
             if (!class_exists('VirtueMartModelCustomfields')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'customfields.php';
             }
             VirtueMartModelCustomfields::storeProductCustomfields('product', $data, $product_data->virtuemart_product_id);
         }
     }
     //vmdebug('use_desired_price '.$this->_id.' '.$data['use_desired_price']);
     if (!$isChild and isset($data['use_desired_price']) and $data['use_desired_price'] == "1") {
         if (!class_exists('calculationHelper')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
         }
         $calculator = calculationHelper::getInstance();
         $data['product_price'] = $calculator->calculateCostprice($this->_id, $data);
         unset($data['use_desired_price']);
         // 			vmdebug('product_price '.$data['product_price']);
     }
     if (isset($data['product_price'])) {
         if ($isChild) {
             unset($data['product_override_price']);
             unset($data['override']);
         }
         $data = $this->updateXrefAndChildTables($data, 'product_prices');
     }
     if (!empty($data['childs'])) {
         foreach ($data['childs'] as $productId => $child) {
             $child['product_parent_id'] = $data['virtuemart_product_id'];
             $child['virtuemart_product_id'] = $productId;
             $this->store($child, TRUE);
         }
     }
     if (!$isChild) {
         $data = $this->updateXrefAndChildTables($data, 'product_shoppergroups');
         $data = $this->updateXrefAndChildTables($data, 'product_manufacturers');
         if (!empty($data['categories']) && count($data['categories']) > 0) {
             $data['virtuemart_category_id'] = $data['categories'];
         } else {
             $data['virtuemart_category_id'] = array();
         }
         $data = $this->updateXrefAndChildTables($data, 'product_categories', TRUE);
         // Update waiting list
         //TODO what is this doing?
         if (!empty($data['notify_users'])) {
             if ($data['product_in_stock'] > 0 && $data['notify_users'] == '1') {
                 $waitinglist = VmModel::getModel('Waitinglist');
                 $waitinglist->notifyList($data['virtuemart_product_id']);
             }
         }
         // Process the images
//.........这里部分代码省略.........
开发者ID:alesconti,项目名称:FF_2015,代码行数:101,代码来源:product.php

示例3: store

 /**
  * Store a product
  *
  * @author RolandD
  * @author Max Milbers
  * @access public
  */
 public function store(&$product, $isChild = FALSE)
 {
     if ($product) {
         $data = (array) $product;
     }
     //vmdebug('my data in product store ',$data);
     if (isset($data['intnotes'])) {
         $data['intnotes'] = trim($data['intnotes']);
     }
     // Setup some place holders
     $product_data = $this->getTable('products');
     //Set the product packaging
     if (array_key_exists('product_box', $data)) {
         $data['product_packaging'] = $data['product_box'] << 16 | $data['product_packaging'] & 0xffff;
     }
     // 		if(VmConfig::get('productlayout') == $data['layout']){
     // 			$data['layout'] = 0;
     // 		}
     //with the true, we do preloading and preserve so old values note by Max Milbers
     //	$product_data->bindChecknStore ($data, $isChild);
     $product_data->bindChecknStore($data, TRUE);
     $errors = $product_data->getErrors();
     foreach ($errors as $error) {
         vmError($error);
         return FALSE;
     }
     $this->_id = $data['virtuemart_product_id'] = $product_data->virtuemart_product_id;
     if (empty($this->_id)) {
         return FALSE;
     }
     // 	 	JPluginHelper::importPlugin('vmcustom');
     // 	 	$dispatcher = JDispatcher::getInstance();
     // 	 	$error = $dispatcher->trigger('plgVmOnStoreProduct', array('product',$data,$product_data->virtuemart_product_id));
     //We may need to change this, the reason it is not in the other list of commands for parents
     if (!$isChild) {
         if (isset($data['save_customfields'])) {
             if (!class_exists('VirtueMartModelCustomfields')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'customfields.php';
             }
             VirtueMartModelCustomfields::storeProductCustomfields('product', $data, $product_data->virtuemart_product_id);
         }
     }
     // 		vmdebug('use_desired_price '.$this->_id.' '.$data['use_desired_price']);
     if (!$isChild and isset($data['use_desired_price']) and $data['use_desired_price'] == "1") {
         if (!class_exists('calculationHelper')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
         }
         $calculator = calculationHelper::getInstance();
         $data['product_price'] = $calculator->calculateCostprice($this->_id, $data);
         unset($data['use_desired_price']);
         // 			vmdebug('product_price '.$data['product_price']);
     }
     if (isset($data['product_price'])) {
         if ($isChild) {
             unset($data['product_override_price']);
             unset($data['override']);
         }
         $data = $this->updateXrefAndChildTables($data, 'product_prices');
     }
     if (!empty($data['childs'])) {
         foreach ($data['childs'] as $productId => $child) {
             $child['product_parent_id'] = $data['virtuemart_product_id'];
             $child['virtuemart_product_id'] = $productId;
             $this->store($child, TRUE);
         }
     }
     if (!$isChild) {
         $data = $this->updateXrefAndChildTables($data, 'product_shoppergroups');
         $data = $this->updateXrefAndChildTables($data, 'product_manufacturers');
         if (!empty($data['categories']) && count($data['categories']) > 0) {
             $data['virtuemart_category_id'] = $data['categories'];
         } else {
             $data['virtuemart_category_id'] = array();
         }
         $data = $this->updateXrefAndChildTables($data, 'product_categories', TRUE);
         // Update waiting list
         //TODO what is this doing?
         if (!empty($data['notify_users'])) {
             if ($data['product_in_stock'] > 0 && $data['notify_users'] == '1') {
                 $waitinglist = VmModel::getModel('Waitinglist');
                 $waitinglist->notifyList($data['virtuemart_product_id']);
             }
         }
         // Process the images
         $mediaModel = VmModel::getModel('Media');
         $mediaModel->storeMedia($data, 'product');
         $errors = $mediaModel->getErrors();
         foreach ($errors as $error) {
             vmError($error);
         }
     }
     return $product_data->virtuemart_product_id;
 }
开发者ID:srbsnkr,项目名称:sellingonlinemadesimple,代码行数:100,代码来源:product.php

示例4: store

 /**
  * Store a product
  *
  * @author RolandD
  * @author Max Milbers
  * @access public
  */
 public function store(&$product, $isChild = FALSE)
 {
     JRequest::checkToken() or jexit('Invalid Token');
     if ($product) {
         $data = (array) $product;
     }
     if (!class_exists('Permissions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
     }
     $perm = Permissions::getInstance();
     $superVendor = $perm->isSuperVendor();
     if (empty($superVendor)) {
         vmError('You are not a vendor or administrator, storing of product cancelled');
         return FALSE;
     }
     if (isset($data['intnotes'])) {
         $data['intnotes'] = trim($data['intnotes']);
     }
     // Setup some place holders
     $product_data = $this->getTable('products');
     //Set the product packaging
     if (array_key_exists('product_packaging', $data)) {
         $data['product_packaging'] = str_replace(',', '.', $data['product_packaging']);
     }
     //with the true, we do preloading and preserve so old values note by Max Milbers
     //	$product_data->bindChecknStore ($data, $isChild);
     $stored = $product_data->bindChecknStore($data, TRUE);
     $errors = $product_data->getErrors();
     if (!$stored or count($errors) > 0) {
         foreach ($errors as $error) {
             vmError('Product store ' . $error);
         }
         if (!$stored) {
             vmError('You are not an administrator or the correct vendor, storing of product cancelled');
         }
         return FALSE;
     }
     $this->_id = $data['virtuemart_product_id'] = (int) $product_data->virtuemart_product_id;
     if (empty($this->_id)) {
         vmError('Product not stored, no id');
         return FALSE;
     }
     //We may need to change this, the reason it is not in the other list of commands for parents
     if (!$isChild) {
         if (!empty($data['save_customfields'])) {
             if (!class_exists('VirtueMartModelCustomfields')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'customfields.php';
             }
             VirtueMartModelCustomfields::storeProductCustomfields('product', $data, $product_data->virtuemart_product_id);
         }
     }
     // Get old IDS
     $this->_db->setQuery('SELECT `virtuemart_product_price_id` FROM `#__virtuemart_product_prices` WHERE virtuemart_product_id =' . $this->_id);
     $old_price_ids = $this->_db->loadResultArray();
     foreach ($data['mprices']['product_price'] as $k => $product_price) {
         $pricesToStore = array();
         $pricesToStore['virtuemart_product_id'] = $this->_id;
         $pricesToStore['virtuemart_product_price_id'] = (int) $data['mprices']['virtuemart_product_price_id'][$k];
         if (!$isChild) {
             //$pricesToStore['basePrice'] = $data['mprices']['basePrice'][$k];
             $pricesToStore['product_override_price'] = $data['mprices']['product_override_price'][$k];
             $pricesToStore['override'] = (int) $data['mprices']['override'][$k];
             $pricesToStore['virtuemart_shoppergroup_id'] = (int) $data['mprices']['virtuemart_shoppergroup_id'][$k];
             $pricesToStore['product_tax_id'] = (int) $data['mprices']['product_tax_id'][$k];
             $pricesToStore['product_discount_id'] = (int) $data['mprices']['product_discount_id'][$k];
             $pricesToStore['product_currency'] = (int) $data['mprices']['product_currency'][$k];
             $pricesToStore['product_price_publish_up'] = $data['mprices']['product_price_publish_up'][$k];
             $pricesToStore['product_price_publish_down'] = $data['mprices']['product_price_publish_down'][$k];
             $pricesToStore['price_quantity_start'] = (int) $data['mprices']['price_quantity_start'][$k];
             $pricesToStore['price_quantity_end'] = (int) $data['mprices']['price_quantity_end'][$k];
         }
         if (!$isChild and isset($data['mprices']['use_desired_price'][$k]) and $data['mprices']['use_desired_price'][$k] == "1") {
             if (!class_exists('calculationHelper')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
             }
             $calculator = calculationHelper::getInstance();
             $pricesToStore['salesPrice'] = $data['mprices']['salesPrice'][$k];
             $pricesToStore['product_price'] = $data['mprices']['product_price'][$k] = $calculator->calculateCostprice($this->_id, $pricesToStore);
             unset($data['mprices']['use_desired_price'][$k]);
         } else {
             $pricesToStore['product_price'] = $data['mprices']['product_price'][$k];
         }
         if (isset($data['mprices']['product_price'][$k])) {
             if ($isChild) {
                 unset($data['mprices']['product_override_price'][$k]);
                 unset($pricesToStore['product_override_price']);
                 unset($data['mprices']['override'][$k]);
                 unset($pricesToStore['override']);
             }
             //$data['mprices'][$k] = $data['virtuemart_product_id'];
             $this->updateXrefAndChildTables($pricesToStore, 'product_prices', $isChild);
             $key = array_search($pricesToStore['virtuemart_product_price_id'], $old_price_ids);
             if ($key !== false) {
//.........这里部分代码省略.........
开发者ID:romuland,项目名称:khparts,代码行数:101,代码来源:product.php


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