本文整理汇总了PHP中Magento\Mtf\Fixture\InjectableFixture::getCustomOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP InjectableFixture::getCustomOptions方法的具体用法?PHP InjectableFixture::getCustomOptions怎么用?PHP InjectableFixture::getCustomOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Mtf\Fixture\InjectableFixture
的用法示例。
在下文中一共展示了InjectableFixture::getCustomOptions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareOptions
/**
* Preparation options before comparing.
*
* @param InjectableFixture $product
* @return array
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function prepareOptions(InjectableFixture $product)
{
$result = [];
$customOptions = $product->getCustomOptions();
$actualPrice = $this->getProductActualPrice($product);
foreach ($customOptions as $customOption) {
$customOptionsPriceType = isset($customOption['options']['price_type']) ? $customOption['options']['price_type'] : null;
if ($customOptionsPriceType) {
if ($customOptionsPriceType === 'Percent') {
$customOptionPrice = $customOption['options']['price'];
$customOption['options']['price'] = $this->calculatePrice($actualPrice, $customOptionPrice);
}
$customOption['options'] = array_diff_key($customOption['options'], array_flip($this->skippedFieldOptions));
} else {
foreach ($customOption['options'] as &$option) {
if ('Percent' === $option['price_type']) {
$option['price'] = $this->calculatePrice($actualPrice, $option['price']);
}
$option = array_diff_key($option, array_flip($this->skippedFieldOptions));
}
}
$customOption['type'] = explode('/', $customOption['type'])[1];
$result[$customOption['title']] = $customOption;
}
return $result;
}
示例2: prepareFixturePrice
/**
* Prepare product price from fixture.
*
* @param InjectableFixture $product
* @return float
*/
protected function prepareFixturePrice(InjectableFixture $product)
{
/** @var CatalogProductSimple $product */
$customOptions = $product->getCustomOptions();
$checkoutData = $product->getCheckoutData();
$checkoutCustomOptions = isset($checkoutData['options']['custom_options']) ? $checkoutData['options']['custom_options'] : [];
if (isset($checkoutData['cartItem'])) {
$fixturePrice = $checkoutData['cartItem']['price'];
} else {
$fixturePrice = $product->getPrice();
$groupPrice = $product->getGroupPrice();
$specialPrice = $product->getSpecialPrice();
if ($groupPrice) {
$groupPrice = reset($groupPrice);
$fixturePrice = $groupPrice['price'];
}
if ($specialPrice) {
$fixturePrice = $specialPrice;
}
foreach ($checkoutCustomOptions as $checkoutOption) {
$attributeKey = str_replace('attribute_key_', '', $checkoutOption['title']);
$optionKey = str_replace('option_key_', '', $checkoutOption['value']);
$option = $customOptions[$attributeKey]['options'][$optionKey];
if ('Fixed' == $option['price_type']) {
$fixturePrice += $option['price'];
} else {
$fixturePrice += $fixturePrice / 100 * $option['price'];
}
}
}
return $fixturePrice;
}
示例3: fillOptions
/**
* Fill in the option specified for the product.
*
* @param InjectableFixture $product
* @return void
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function fillOptions(InjectableFixture $product)
{
$dataConfig = $product->getDataConfig();
$typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null;
$checkoutData = null;
/** @var CatalogProductSimple $product */
if ($this->hasRender($typeId)) {
$this->callRender($typeId, 'fillOptions', ['product' => $product]);
}
/** @var CatalogProductSimple $product */
$checkoutData = $product->getCheckoutData();
if (!isset($checkoutData['options']['custom_options'])) {
return;
}
$customOptions = $product->getCustomOptions();
if (isset($customOptions)) {
$checkoutCustomOptions = $this->prepareCheckoutData($customOptions, $checkoutData['options']['custom_options']);
$this->getCustomOptionsBlock()->fillCustomOptions($checkoutCustomOptions);
}
}
示例4: getOptions
/**
* Get product options.
*
* @param InjectableFixture $product
* @return array
* @throws \Exception
*/
public function getOptions(InjectableFixture $product)
{
$dataOptions = $product->hasData('custom_options') ? $product->getCustomOptions() : [];
if (empty($dataOptions)) {
return $dataOptions;
}
$listCustomOptions = $this->getListOptions();
$result = [];
foreach ($dataOptions as $option) {
$title = $option['title'];
if (!isset($listCustomOptions[$title])) {
throw new \Exception("Can't find option: \"{$title}\"");
}
/** @var Element $optionElement */
$optionElement = $listCustomOptions[$title];
$option['type'] = explode('/', $option['type'])[1];
$typeMethod = preg_replace('/[^a-zA-Z]/', '', $option['type']);
$getTypeData = 'get' . ucfirst(strtolower($typeMethod)) . 'Data';
$optionData = $this->{$getTypeData}($optionElement);
$optionData['title'] = $title;
$optionData['type'] = $option['type'];
$optionData['is_require'] = $optionElement['title']->find($this->required, Locator::SELECTOR_XPATH)->isVisible() ? 'Yes' : 'No';
$result[$title] = $optionData;
}
return ['custom_options' => $result];
}