当前位置: 首页>>代码示例>>PHP>>正文


PHP InjectableFixture::getConfigurableOptions方法代码示例

本文整理汇总了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;
 }
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:33,代码来源:ConfigurableOptions.php

示例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;
 }
开发者ID:cewolf2002,项目名称:magento,代码行数:23,代码来源:AssertConfigurableProductInItemsOrderedGrid.php

示例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);
 }
开发者ID:hientruong90,项目名称:ee_14_installer,代码行数:24,代码来源:ConfigurableProductView.php


注:本文中的Magento\Mtf\Fixture\InjectableFixture::getConfigurableOptions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。