Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ProductDetails.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Mtf\Client\Element\SimpleElement;
11 
15 class ProductDetails extends Section
16 {
22  protected $categoryIds = '.admin__field[data-index="category_ids"]';
23 
29  protected $newCategoryRootElement = '.product_form_product_form_create_category_modal';
30 
38  protected function dataMapping(array $fields = null, $parent = null)
39  {
40  if (isset($fields['custom_attribute'])) {
41  $this->placeholders = ['attribute_code' => $fields['custom_attribute']['value']['code']];
42  $this->applyPlaceholders();
43  }
44  return parent::dataMapping($fields, $parent);
45  }
46 
54  public function setFieldsData(array $fields, SimpleElement $element = null)
55  {
56  $data = $this->dataMapping($fields);
57  // Select attribute set
58  if (isset($data['attribute_set_id'])) {
59  $this->_fill([$data['attribute_set_id']], $element);
60  unset($data['attribute_set_id']);
61  }
62  // Select categories
63  if (isset($data['category_ids'])) {
64  if (isset($fields['category_ids']['source'])
65  && $fields['category_ids']['source']->getCategories() !== null
66  && !$fields['category_ids']['source']->getCategories()[0]->hasData('id')
67  ) {
68  $this->blockFactory->create(
69  \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\ProductDetails\NewCategoryIds::class,
70  ['element' => $this->browser->find($this->newCategoryRootElement)]
71  )->addNewCategory($fields['category_ids']['source']->getCategories()[0]);
72  } else {
73  $this->_fill([$data['category_ids']], $element);
74  }
75  unset($data['category_ids']);
76  }
77 
78  $this->_fill($data, $element);
79 
80  return $this;
81  }
82 }
$fields
Definition: details.phtml:14
$element
Definition: element.phtml:12