本文整理汇总了PHP中VirtueMartModelCustomfields::setParameterableByFieldType方法的典型用法代码示例。如果您正苦于以下问题:PHP VirtueMartModelCustomfields::setParameterableByFieldType方法的具体用法?PHP VirtueMartModelCustomfields::setParameterableByFieldType怎么用?PHP VirtueMartModelCustomfields::setParameterableByFieldType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VirtueMartModelCustomfields
的用法示例。
在下文中一共展示了VirtueMartModelCustomfields::setParameterableByFieldType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storeProductCustomfields
public function storeProductCustomfields($table, $datas, $id)
{
//vmdebug('storeProductCustomfields',$datas);
JSession::checkToken() or jexit('Invalid Token, in store customfields');
//Sanitize id
$id = (int) $id;
//Table whitelist
$tableWhiteList = array('product', 'category', 'manufacturer');
if (!in_array($table, $tableWhiteList)) {
return false;
}
// Get old IDS
$this->_db->setQuery('SELECT `virtuemart_customfield_id` FROM `#__virtuemart_' . $table . '_customfields` as `PC` WHERE `PC`.virtuemart_' . $table . '_id =' . $id);
$old_customfield_ids = $this->_db->loadColumn();
if (isset($datas['custom_param'])) {
$params = true;
} else {
$params = false;
}
if (isset($datas['field'])) {
//vmdebug('datas save',$datas);
$customfieldIds = array();
foreach ($datas['field'] as $key => $fields) {
$fields['virtuemart_' . $table . '_id'] = $id;
$tableCustomfields = $this->getTable($table . '_customfields');
$tableCustomfields->setPrimaryKey('virtuemart_product_id');
if (!empty($datas['custom_param'][$key]) and !isset($datas['cloned_product_id'])) {
if (array_key_exists($key, $datas['custom_param'])) {
$fields['custom_param'] = json_encode($datas['custom_param'][$key]);
}
}
VirtueMartModelCustomfields::setParameterableByFieldType($tableCustomfields, $fields['field_type']);
if (!isset($datas['cloned_product_id'])) {
VirtueMartModelCustomfields::bindParameterableByFieldType($tableCustomfields, $fields['field_type']);
}
$tableCustomfields->bindChecknStore($fields);
$errors = $tableCustomfields->getErrors();
foreach ($errors as $error) {
vmError($error);
}
$key = array_search($fields['virtuemart_customfield_id'], $old_customfield_ids);
if ($key !== false) {
unset($old_customfield_ids[$key]);
}
// vmdebug('datas clone',$old_customfield_ids,$fields);
}
}
if (count($old_customfield_ids)) {
// delete old unused Customfields
$this->_db->setQuery('DELETE FROM `#__virtuemart_' . $table . '_customfields` WHERE `virtuemart_customfield_id` in ("' . implode('","', $old_customfield_ids) . '") ');
$this->_db->execute();
}
JPluginHelper::importPlugin('vmcustom');
$dispatcher = JDispatcher::getInstance();
if (isset($datas['plugin_param']) and is_array($datas['plugin_param']) and !isset($datas['cloned_product_id'])) {
foreach ($datas['plugin_param'] as $key => $plugin_param) {
$dispatcher->trigger('plgVmOnStoreProduct', array($datas, $plugin_param));
}
} else {
if (isset($datas['field']) and is_array($datas['field']) and isset($datas['cloned_product_id'])) {
foreach ($datas['field'] as $key => $plugin_param) {
if ($plugin_param['field_type'] !== 'E') {
continue;
}
$datas['plugin_param'] = $datas['field'];
$dispatcher->trigger('plgVmOnCloneProduct', array($datas, $plugin_param, $datas['cloned_product_id']));
}
}
}
}