當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FixtureInterface::getConfigurableAttributesData方法代碼示例

本文整理匯總了PHP中Magento\Mtf\Fixture\FixtureInterface::getConfigurableAttributesData方法的典型用法代碼示例。如果您正苦於以下問題:PHP FixtureInterface::getConfigurableAttributesData方法的具體用法?PHP FixtureInterface::getConfigurableAttributesData怎麽用?PHP FixtureInterface::getConfigurableAttributesData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Mtf\Fixture\FixtureInterface的用法示例。


在下文中一共展示了FixtureInterface::getConfigurableAttributesData方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getOptions

 /**
  * Get configurable product options
  *
  * @param FixtureInterface|null $product [optional]
  * @return array
  * @throws \Exception
  */
 public function getOptions(FixtureInterface $product)
 {
     /** @var ConfigurableProduct $product */
     $attributesData = $product->hasData('configurable_attributes_data') ? $product->getConfigurableAttributesData()['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 SimpleElement $optionElement */
         $optionElement = $listOptions[$title];
         $typeMethod = preg_replace('/[^a-zA-Z]/', '', $option['frontend_input']);
         $getTypeData = 'get' . ucfirst(strtolower($typeMethod)) . 'Data';
         $optionData = $this->{$getTypeData}($optionElement);
         $optionData['title'] = $title;
         $optionData['type'] = $option['frontend_input'];
         $optionData['is_require'] = $optionElement->find($this->required, Locator::SELECTOR_XPATH)->isVisible() ? 'Yes' : 'No';
         foreach ($optionData['options'] as $key => $value) {
             $optionData['options'][$key]['price'] = $this->getOptionPrice($title, $value['title']);
         }
         $result[$title] = $optionData;
     }
     return $result;
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:33,代碼來源:ConfigurableOptions.php

示例2: prepareVariationsMatrix

 /**
  * Preparing matrix data
  *
  * @param FixtureInterface $product
  * @return array
  */
 protected function prepareVariationsMatrix(FixtureInterface $product)
 {
     /** @var ConfigurableAttributesData $configurableAttributesData */
     $configurableAttributesData = $product->getDataFieldConfig('configurable_attributes_data')['source'];
     $attributesData = $configurableAttributesData->getAttributesData();
     $assignedProducts = $configurableAttributesData->getProducts();
     $matrixData = $product->getConfigurableAttributesData()['matrix'];
     $result = [];
     foreach ($matrixData as $variationKey => $variation) {
         // For assigned products doesn't send data about them
         if (isset($assignedProducts[$variationKey])) {
             continue;
         }
         $compositeKeys = explode(' ', $variationKey);
         $keyIds = [];
         $configurableAttribute = [];
         foreach ($compositeKeys as $compositeKey) {
             list($attributeKey, $optionKey) = explode(':', $compositeKey);
             $attribute = $attributesData[$attributeKey];
             $keyIds[] = $attribute['options'][$optionKey]['id'];
             $configurableAttribute[] = sprintf('"%s":"%s"', $attribute['attribute_code'], $attribute['options'][$optionKey]['id']);
         }
         $keyIds = implode('-', $keyIds);
         $variation['configurable_attribute'] = '{' . implode(',', $configurableAttribute) . '}';
         $result[$keyIds] = $variation;
     }
     return $result;
 }
開發者ID:,項目名稱:,代碼行數:34,代碼來源:

示例3: getOptionsPrices

 /**
  * Get configurable attributes options prices
  *
  * @param FixtureInterface $product
  * @return array
  */
 public function getOptionsPrices(FixtureInterface $product)
 {
     /** @var ConfigurableProduct $product */
     $attributesData = [];
     $productVariations = [];
     if ($product->hasData('configurable_attributes_data')) {
         $attributesData = $product->getConfigurableAttributesData()['attributes_data'];
         $productVariations = $product->getConfigurableAttributesData()['matrix'];
     }
     $productVariations = array_keys($productVariations);
     $result = [];
     foreach ($productVariations as $variation) {
         $variationOptions = explode(' ', $variation);
         $result[$variation]['price'] = $this->getOptionPrice($variationOptions, $attributesData);
     }
     return $result;
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:23,代碼來源:ConfigurableOptions.php

示例4: fillOptions

 /**
  * Fill in the option specified for the product
  *
  * @param FixtureInterface $product
  * @return void
  */
 public function fillOptions(FixtureInterface $product)
 {
     /** @var ConfigurableProduct $product */
     $attributesData = $product->getConfigurableAttributesData()['attributes_data'];
     $checkoutData = $product->getCheckoutData();
     // Prepare attribute data
     foreach ($attributesData as $attributeKey => $attribute) {
         $attributesData[$attributeKey] = ['type' => $attribute['frontend_input'], 'title' => $attribute['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->getCustomOptionsBlock()->fillCustomOptions($checkoutOptionsData);
     parent::fillOptions($product);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:25,代碼來源:View.php

示例5: getProductPrice

 /**
  * Get configurable product price
  *
  * @param FixtureInterface $product
  * @throws \Exception
  * @return int
  */
 protected function getProductPrice(FixtureInterface $product)
 {
     $price = $product->getPrice();
     if (!$this->productsIsConfigured) {
         return $price;
     }
     if (!$product instanceof ConfigurableProduct) {
         throw new \Exception("Product '{$product->getName}()' is not configurable product.");
     }
     $checkoutData = $product->getCheckoutData();
     if ($checkoutData === null) {
         return 0;
     }
     $attributesData = $product->getConfigurableAttributesData()['attributes_data'];
     foreach ($checkoutData['options']['configurable_options'] as $option) {
         $itemOption = $attributesData[$option['title']]['options'][$option['value']];
         $itemPrice = $itemOption['is_percent'] == 'No' ? $itemOption['pricing_value'] : $product->getPrice() / 100 * $itemOption['pricing_value'];
         $price += $itemPrice;
     }
     return $price;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:28,代碼來源:AssertConfigurableProductInItemsOrderedGrid.php


注:本文中的Magento\Mtf\Fixture\FixtureInterface::getConfigurableAttributesData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。