本文整理汇总了PHP中Option::getOptionGroupId方法的典型用法代码示例。如果您正苦于以下问题:PHP Option::getOptionGroupId方法的具体用法?PHP Option::getOptionGroupId怎么用?PHP Option::getOptionGroupId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Option
的用法示例。
在下文中一共展示了Option::getOptionGroupId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verify
public function verify()
{
if (!isset($this->data->price) || !is_numeric($this->data->price)) {
throw new \Exception(Lang::txt('No SKU price set'));
}
if (!isset($this->data->pId) || !is_numeric($this->data->pId)) {
throw new \Exception(Lang::txt('No SKU Product Set'));
}
// Verify that the SKU has all options set (one option from each option group assigned to the parent product)
$product = new Product($this->getProductId());
$productOptionGroups = $product->getOptionGroups();
// Init the set options array()
$optionGroupOptionsSet = array();
// Init the flag whether the extra/useless options are set
$extraOptionsSet = false;
foreach ($this->getOptions() as $oId) {
$option = new Option($oId);
$optionGroupId = $option->getOptionGroupId();
if (in_array($optionGroupId, $productOptionGroups)) {
$optionGroupOptionsSet[] = $optionGroupId;
} else {
// There are some options set that are from option groups not applied to this product
// (most likely due to the removal of the option group from the product.)
$extraOptionsSet = true;
}
}
// At this point option groups options set must be the same as the product options groups, throw exception if not
$missingOptions = array_diff($productOptionGroups, $optionGroupOptionsSet);
if (!empty($missingOptions)) {
throw new \Exception(Lang::txt('Not all product options are set'));
}
if ($extraOptionsSet) {
throw new \Exception(Lang::txt('Extra options are set'));
}
return true;
}
示例2: verify
public function verify()
{
if (!isset($this->data->price) || !is_numeric($this->data->price)) {
throw new \Exception(Lang::txt('No SKU price set'));
}
if (!isset($this->data->pId) || !is_numeric($this->data->pId)) {
throw new \Exception(Lang::txt('No SKU Product Set'));
}
// Verify that the SKU has all options set (one option from each option group assigned to the parent product)
$product = new Product($this->getProductId());
$productOptionGroups = $product->getOptionGroups();
// Init the set options array()
$optionGroupOptionsSet = array();
// Init the flag whether the extra/useless options are set
$extraOptionsSet = false;
foreach ($this->getOptions() as $oId) {
$option = new Option($oId);
$optionGroupId = $option->getOptionGroupId();
if (in_array($optionGroupId, $productOptionGroups)) {
$optionGroupOptionsSet[] = $optionGroupId;
} else {
// There are some options set that are from option groups not applied to this product
// (most likely due to the removal of the option group from the product.) This should never happen.
$extraOptionsSet = true;
}
}
// At this point option groups options set must be the same as the product options groups, throw exception if not
$missingOptions = array_diff($productOptionGroups, $optionGroupOptionsSet);
if (!empty($missingOptions)) {
throw new \Exception(Lang::txt('Not all product options are set'));
}
if ($extraOptionsSet) {
throw new \Exception(Lang::txt('Extra options are set'));
}
// Integrity check
require_once dirname(__DIR__) . DS . 'helpers' . DS . 'Integrity.php';
$integrityCheck = \Integrity::skuIntegrityCheck($this);
if ($integrityCheck->status != 'ok') {
$errorMessage = "Integrity check error:";
foreach ($integrityCheck->errors as $error) {
$errorMessage .= '<br>' . $error;
}
throw new \Exception($errorMessage);
}
return true;
}