本文整理汇总了PHP中ShoppDatabaseObject::metaloader方法的典型用法代码示例。如果您正苦于以下问题:PHP ShoppDatabaseObject::metaloader方法的具体用法?PHP ShoppDatabaseObject::metaloader怎么用?PHP ShoppDatabaseObject::metaloader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShoppDatabaseObject
的用法示例。
在下文中一共展示了ShoppDatabaseObject::metaloader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: metasetloader
public function metasetloader(&$records, &$record, $id = 'id', $property = false, $collate = false, $merge = false)
{
if (isset($this->prices) && !empty($this->prices)) {
$prices =& $this->prices;
} else {
$prices = array();
}
$metamap = array('download' => 'download', 'options' => 'options', 'settings' => 'settings');
$metaclass = array('meta' => 'ShoppMetaObject');
if ('metatype' == $property) {
$property = isset($metamap[$record->type]) ? $metamap[$record->type] : 'meta';
}
if ('download' == $record->type) {
$collate = false;
$data = unserialize($record->value);
foreach (get_object_vars($data) as $prop => $val) {
$record->{$prop} = $val;
}
$clean = array('context', 'type', 'numeral', 'sortorder', 'created', 'modified', 'value');
foreach ($clean as $prop) {
unset($record->{$prop});
}
}
if (isset($record->type) && isset($metaclass[$record->type])) {
$ObjectClass = $metaclass[$record->type];
$Object = new $ObjectClass();
$Object->populate($record);
if (method_exists($Object, 'expopulate')) {
$Object->expopulate();
}
if (is_array($prices) && isset($prices[$Object->{$id}])) {
$target = $prices[$Object->{$id}];
} elseif (isset($this)) {
$target = $this;
}
if (!empty($target)) {
if (is_array($Object->value)) {
foreach ($Object->value as $prop => $setting) {
$target->{$prop} = $setting;
// Determine weight ranges from loaded price settings meta
if ('dimensions' == $prop && isset($setting['weight'])) {
$product = is_array($this->products) ? $this->products[$target->product] : $this->products;
if (!isset($product->min['weight']) || $product->min['weight'] == 0) {
$product->min['weight'] = $product->max['weight'] = $setting['weight'];
}
$product->min['weight'] = min($product->min['weight'], $setting['weight']);
$product->max['weight'] = max($product->max['weight'], $setting['weight']);
}
}
} else {
$target->{$Object->name} = $Object->value;
}
}
return;
}
parent::metaloader($records, $record, $prices, $id, $property, $collate, $merge);
}