/** * 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; }
/** * 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]); }