コード例 #1
0
ファイル: View.php プロジェクト: buskamuza/magento2-skeleton
 /**
  * Fill in the option specified for the product
  *
  * @param FixtureInterface $product
  * @return void
  */
 public function fillOptions(FixtureInterface $product)
 {
     if ($product instanceof InjectableFixture) {
         /** @var ConfigurableProductInjectable $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']];
             }
         }
     } else {
         // TODO: Removed after refactoring(removed) old product fixture.
         /** @var ConfigurableProduct $product */
         $attributesData = $product->getConfigurableAttributes();
         $checkoutData = $product->getCheckoutData();
         // Prepare attributes data
         foreach ($attributesData as $attributeKey => $attribute) {
             $attributesData[$attributeKey] = ['type' => 'dropdown', 'title' => $attribute['label']['value']];
             unset($attribute['label']);
             foreach ($attribute as $optionKey => $option) {
                 $attributesData[$attributeKey]['options'][$optionKey] = ['title' => $option['option_label']['value']];
             }
         }
     }
     $configurableCheckoutData = isset($checkoutData['configurable_options']) ? $checkoutData['configurable_options'] : [];
     $checkoutOptionsData = $this->prepareCheckoutData($attributesData, $configurableCheckoutData);
     $this->getCustomOptionsBlock()->fillCustomOptions($checkoutOptionsData);
     parent::fillOptions($product);
 }
コード例 #2
0
ファイル: View.php プロジェクト: zhangjiachao/magento2
 /**
  * Fill specified option for the product
  *
  * @param FixtureInterface $product
  * @return void
  */
 public function fillOptions(FixtureInterface $product)
 {
     /** @var DownloadableProductInjectable $product */
     $productData = $product->getData();
     $downloadableLinks = isset($productData['downloadable_links']['downloadable']['link']) ? $productData['downloadable_links']['downloadable']['link'] : [];
     $data = $product->getCheckoutData()['options'];
     // Replace link key to label
     foreach ($data['links'] as $key => $linkData) {
         $linkKey = str_replace('link_', '', $linkData['label']);
         $linkData['label'] = isset($downloadableLinks[$linkKey]['title']) ? $downloadableLinks[$linkKey]['title'] : $linkData['label'];
         $data['links'][$key] = $linkData;
     }
     $this->getDownloadableLinksBlock()->fill($data['links']);
     parent::fillOptions($product);
 }
コード例 #3
0
ファイル: View.php プロジェクト: kidaa30/magento2-platformsh
 /**
  * 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);
 }
コード例 #4
0
ファイル: View.php プロジェクト: buskamuza/magento2-skeleton
 /**
  * Fill in the option specified for the product
  *
  * @param FixtureInterface $product
  * @return void
  */
 public function fillOptions(FixtureInterface $product)
 {
     if ($product instanceof InjectableFixture) {
         /** @var \Magento\Bundle\Test\Fixture\CatalogProductBundle $product */
         $checkoutData = $product->getCheckoutData();
         $bundleCheckoutData = isset($checkoutData['bundle_options']) ? $checkoutData['bundle_options'] : [];
     } else {
         // TODO: Removed after refactoring(removed) old product fixture.
         /** @var \Magento\Bundle\Test\Fixture\BundleFixed $product */
         $bundleCheckoutData = $product->getSelectionData();
     }
     $this->_rootElement->find($this->customizeButton)->click();
     $this->getBundleBlock()->fillBundleOptions($bundleCheckoutData);
     parent::fillOptions($product);
 }
コード例 #5
0
ファイル: View.php プロジェクト: zhangjiachao/magento2
 /**
  * Fill specified option for the product
  *
  * @param FixtureInterface $product
  * @return void
  */
 public function fillOptions(FixtureInterface $product)
 {
     $this->getGroupedProductBlock()->fill($product);
     parent::fillOptions($product);
 }