本文整理汇总了PHP中Magento\Mtf\Fixture\InjectableFixture::getConfigurableOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP InjectableFixture::getConfigurableOptions方法的具体用法?PHP InjectableFixture::getConfigurableOptions怎么用?PHP InjectableFixture::getConfigurableOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Mtf\Fixture\InjectableFixture
的用法示例。
在下文中一共展示了InjectableFixture::getConfigurableOptions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOptions
/**
* Get configurable product options.
*
* @param InjectableFixture|null $product [optional]
* @return array
* @throws \Exception
*/
public function getOptions(InjectableFixture $product)
{
/** @var ConfigurableProduct $product */
$attributesData = $product->hasData('configurable_options') ? $product->getConfigurableOptions()['attributes_data'] : [];
$listOptions = $this->getListOptions();
$result = [];
foreach ($attributesData as $option) {
$title = $option['label'];
if (!isset($listOptions[$title])) {
throw new \Exception("Can't find option: \"{$title}\"");
}
/** @var Element $optionElement */
$optionElement = $listOptions[$title];
$type = $option['frontend_input'];
$option['frontend_input'] = explode('/', $option['frontend_input'])[1];
$typeMethod = preg_replace('/[^a-zA-Z]/', '', $option['frontend_input']);
$getTypeData = 'get' . ucfirst(strtolower($typeMethod)) . 'Data';
$optionData = $this->{$getTypeData}($optionElement);
$optionData['title'] = $title;
$optionData['type'] = $type;
$isRequire = $this->_rootElement->find(sprintf($this->required, $title), Locator::SELECTOR_XPATH)->isVisible();
$optionData['is_require'] = $isRequire ? 'Yes' : 'No';
$result[$title] = $optionData;
}
return $result;
}
示例2: getProductPrice
/**
* Get configurable product price.
*
* @param InjectableFixture $product
* @return int
*/
protected function getProductPrice(InjectableFixture $product)
{
$price = $product->getPrice();
if (!$this->productsIsConfigured) {
return $price;
}
$checkoutData = $product->getCheckoutData();
if ($checkoutData === null) {
return 0;
}
$attributesData = $product->getConfigurableOptions()['attributes_data'];
foreach ($checkoutData['options']['configurable_options'] as $option) {
$itemOption = $attributesData[$option['title']]['options'][$option['value']];
$price += $itemOption['price_type'] == 'Fixed' ? $itemOption['price'] : $product->getPrice() / 100 * $itemOption['price'];
}
return $price;
}
示例3: fillOptions
/**
* Fill in the option specified for the product.
*
* @param InjectableFixture $product
* @return void
*/
public function fillOptions(InjectableFixture $product)
{
/** @var ConfigurableProduct $product */
$attributesData = $product->getConfigurableOptions()['attributes_data'];
$checkoutData = $product->getCheckoutData();
// Prepare attribute data
foreach ($attributesData as $attributeKey => $attribute) {
$attributesData[$attributeKey] = ['type' => $attribute['frontend_input'], 'title' => $attribute['frontend_label'], 'options' => []];
foreach ($attribute['options'] as $optionKey => $option) {
$attributesData[$attributeKey]['options'][$optionKey] = ['title' => $option['label']];
}
$attributesData[$attributeKey]['options'] = array_values($attributesData[$attributeKey]['options']);
}
$attributesData = array_values($attributesData);
$configurableCheckoutData = isset($checkoutData['options']['configurable_options']) ? $checkoutData['options']['configurable_options'] : [];
$checkoutOptionsData = $this->prepareCheckoutData($attributesData, $configurableCheckoutData);
$this->getConfigurableOptionsBlock()->fillOptions($checkoutOptionsData);
}