コード例 #1
0
 /**
  * Provide data to product from new attribute
  *
  * @param ProductAttribute $attribute
  * @return void
  */
 public function provideNewAttributeData(ProductAttribute $attribute)
 {
     $options = $attribute->getOptionLabels();
     $placeholders['new_attribute_label'] = $attribute->getFrontendLabel();
     $placeholders['new_attribute_option_1_label'] = $options[0];
     $placeholders['new_attribute_option_2_label'] = $options[1];
     $this->_applyPlaceholders($this->_data, $placeholders);
 }
コード例 #2
0
 /**
  * Get data for curl POST params
  *
  * @param ProductAttribute $fixture
  * @return array
  */
 protected function getPostParams(ProductAttribute $fixture)
 {
     $data = $this->prepareParams($fixture->getData('fields'));
     $options = $fixture->getOptions();
     foreach ($options as $option) {
         $data = array_merge($data, $this->prepareParams($option));
     }
     return $data;
 }
コード例 #3
0
 /**
  * Add new attribute to product
  *
  * @param ProductAttribute $attribute
  * @return void
  */
 protected function addNewAttribute(ProductAttribute $attribute)
 {
     $attributeData = $attribute->getData();
     $attributeFields = [];
     foreach ($attributeData['fields'] as $name => $field) {
         $attributeFields[$name] = $field['value'];
     }
     $attributeFields['options'] = $attributeData['options']['value'];
     $createProductPage = Factory::getPageFactory()->getCatalogProductNew();
     $productForm = $createProductPage->getProductForm();
     $productForm->openTab('variations');
     /** @var \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config $variations */
     $variations = $productForm->getTabElement('variations');
     $variations->showContent();
     $variations->getAttributeBlock()->fillAttributes([$attributeFields]);
 }