/** * Prepare Catalog Attribute Set data * * @param CatalogAttributeSet $attributeSet * @return void */ protected function prepareData(CatalogAttributeSet $attributeSet) { if (!$attributeSet->hasData('attribute_set_id')) { $attributeSet->persist(); } $this->data = $attributeSet->getAttributeSetName(); $this->attributeSet = $attributeSet; }
/** * Create attribute set. * * @return FixtureInterface */ protected function createAttributeSet() { if (!$this->attributeSet) { $this->attributeSet = $this->fixtureFactory->createByCode('catalogAttributeSet', ['dataset' => 'custom_attribute_set', 'data' => ['assigned_attributes' => ['attributes' => array_values($this->attributes)]]]); $this->attributeSet->persist(); } return $this->attributeSet; }
/** * Run CreateProductAttributeEntity test * * @param CatalogProductAttribute $productAttribute * @param CatalogProductAttributeIndex $attributeIndex * @param CatalogProductAttributeNew $attributeNew * @param CatalogAttributeSet $productTemplate * @return void */ public function testCreateProductAttribute(CatalogProductAttribute $productAttribute, CatalogProductAttributeIndex $attributeIndex, CatalogProductAttributeNew $attributeNew, CatalogAttributeSet $productTemplate) { //Precondition $productTemplate->persist(); //Steps $attributeIndex->open(); $attributeIndex->getPageActionsBlock()->addNew(); $attributeNew->getAttributeForm()->fill($productAttribute); $attributeNew->getPageActions()->save(); }
/** * Run DeleteAssignedToTemplateProductAttribute test * * @param CatalogAttributeSet $productTemplate * @return array */ public function test(CatalogAttributeSet $productTemplate) { // Precondition $productTemplate->persist(); // Steps $filter = ['attribute_code' => $productTemplate->getDataFieldConfig('assigned_attributes')['source']->getAttributes()[0]->getAttributeCode()]; $this->attributeIndex->open(); $this->attributeIndex->getGrid()->searchAndOpen($filter); $this->attributeNew->getPageActions()->delete(); return ['productTemplate' => $productTemplate]; }
/** * Run UpdateProductAttributeEntity test * * @param CatalogProductAttribute $productAttributeOriginal * @param CatalogProductAttribute $attribute * @param CatalogAttributeSet $productTemplate * @param CatalogProductAttributeIndex $attributeIndex * @param CatalogProductAttributeNew $attributeNew * @return void */ public function testUpdateProductAttribute(CatalogProductAttribute $productAttributeOriginal, CatalogProductAttribute $attribute, CatalogAttributeSet $productTemplate, CatalogProductAttributeIndex $attributeIndex, CatalogProductAttributeNew $attributeNew) { //Precondition $productTemplate->persist(); $productAttributeOriginal->persist(); $filter = ['attribute_code' => $productAttributeOriginal->getAttributeCode()]; //Steps $attributeIndex->open(); $attributeIndex->getGrid()->searchAndOpen($filter); $attributeNew->getAttributeForm()->fill($attribute); $attributeNew->getPageActions()->save(); }
/** * Run CreateProductAttributeEntity test * * @param CatalogProductAttribute $productAttribute * @param CatalogProductAttributeIndex $attributeIndex * @param CatalogProductAttributeNew $attributeNew * @param CatalogAttributeSet $productTemplate * @return array */ public function testCreateProductAttribute(CatalogProductAttribute $productAttribute, CatalogProductAttributeIndex $attributeIndex, CatalogProductAttributeNew $attributeNew, CatalogAttributeSet $productTemplate) { $this->markTestIncomplete('MAGETWO-27282'); //Precondition $productTemplate->persist(); //Steps $attributeIndex->open(); $attributeIndex->getPageActionsBlock()->addNew(); $attributeNew->getAttributeForm()->fill($productAttribute); $attributeNew->getPageActions()->save(); return ['attribute' => $productAttribute]; }
/** * Run DeleteAttributeSet test * * @param FixtureFactory $fixtureFactory * @param CatalogAttributeSet $productTemplate * @return array */ public function test(FixtureFactory $fixtureFactory, CatalogAttributeSet $productTemplate) { // Precondition $productTemplate->persist(); $product = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'default', 'data' => ['attribute_set_id' => ['attribute_set' => $productTemplate]]]); $product->persist(); // Steps $filter = ['set_name' => $productTemplate->getAttributeSetName()]; $this->productSetIndex->open(); $this->productSetIndex->getGrid()->searchAndOpen($filter); $this->productSetEdit->getPageActions()->delete(); return ['product' => $product]; }
/** * Run test. * * @param CatalogAttributeSet $attributeSet * @return array */ public function test(CatalogAttributeSet $attributeSet) { // Precondition $attributeSet->persist(); $attribute = $attributeSet->getDataFieldConfig('assigned_attributes')['source']->getAttributes()[0]; // Steps $filter = ['attribute_code' => $attribute->getAttributeCode()]; $this->attributeIndex->open(); $this->attributeIndex->getGrid()->searchAndOpen($filter); $this->attributeNew->getPageActions()->delete(); $this->attributeNew->getModalBlock()->acceptAlert(); return ['attributeSet' => $attributeSet, 'attribute' => $attribute]; }
/** * Run UpdateProductAttributeEntity test * * @param CatalogProductAttribute $productAttributeOriginal * @param CatalogProductAttribute $attribute * @param CatalogAttributeSet $attributeSet * @param CatalogProductAttributeIndex $attributeIndex * @param CatalogProductAttributeNew $attributeNew * @param CatalogProductSimple $productSimple * @return array */ public function testUpdateProductAttribute(CatalogProductAttribute $productAttributeOriginal, CatalogProductAttribute $attribute, CatalogAttributeSet $attributeSet, CatalogProductAttributeIndex $attributeIndex, CatalogProductAttributeNew $attributeNew, CatalogProductSimple $productSimple) { //Precondition $attributeSet->persist(); $productAttributeOriginal->persist(); $filter = ['attribute_code' => $productAttributeOriginal->getAttributeCode()]; //Steps $attributeIndex->open(); $attributeIndex->getGrid()->searchAndOpen($filter); $attributeNew->getAttributeForm()->fill($attribute); $attributeNew->getPageActions()->save(); $attribute = $this->prepareAttribute($attribute, $productAttributeOriginal); $productSimple->persist(); return ['product' => $this->prepareProduct($productSimple, $attribute, $attributeSet)]; }
/** * Run UpdateProductTemplate test * * @param CatalogAttributeSet $attributeSet * @param CatalogAttributeSet $attributeSetOriginal * @param CatalogProductAttribute $productAttributeOriginal * @return void */ public function test(CatalogAttributeSet $attributeSet, CatalogAttributeSet $attributeSetOriginal, CatalogProductAttribute $productAttributeOriginal) { // Precondition $attributeSetOriginal->persist(); $productAttributeOriginal->persist(); // Steps $filter = ['set_name' => $attributeSetOriginal->getAttributeSetName()]; $this->productSetIndex->open(); $this->productSetIndex->getGrid()->searchAndOpen($filter); $groupName = $attributeSet->getGroup(); $this->productSetEdit->getAttributeSetEditBlock()->addAttributeSetGroup($groupName); $this->productSetEdit->getAttributeSetEditBlock()->moveAttribute($productAttributeOriginal->getData(), $groupName); $this->productSetEdit->getAttributeSetEditForm()->fill($attributeSet); $this->productSetEdit->getPageActions()->save(); }
/** * Run UpdateProductAttributeEntity test * * @param CatalogProductAttribute $productAttributeOriginal * @param CatalogProductAttribute $attribute * @param CatalogAttributeSet $attributeSet * @param CatalogProductAttributeIndex $attributeIndex * @param CatalogProductAttributeNew $attributeNew * @return array */ public function testUpdateProductAttribute(CatalogProductAttribute $productAttributeOriginal, CatalogProductAttribute $attribute, CatalogAttributeSet $attributeSet, CatalogProductAttributeIndex $attributeIndex, CatalogProductAttributeNew $attributeNew) { //Precondition $attributeSet->persist(); $productAttributeOriginal->persist(); $filter = ['attribute_code' => $productAttributeOriginal->getAttributeCode()]; /** @var CatalogProductSimple $product */ $product = $this->fixtureFactory->createByCode('catalogProductSimple', ['dataset' => 'default', 'data' => ['attribute_set_id' => ['attribute_set' => $attributeSet]]]); $product->persist(); $this->objectManager->create('Magento\\Catalog\\Test\\TestStep\\AddAttributeToAttributeSetStep', ['attribute' => $productAttributeOriginal, 'attributeSet' => $attributeSet])->run(); //Steps $attributeIndex->open(); $attributeIndex->getGrid()->searchAndOpen($filter); $attributeNew->getAttributeForm()->fill($attribute); $attributeNew->getPageActions()->save(); $attribute = $this->prepareAttribute($attribute, $productAttributeOriginal); return ['product' => $this->prepareProduct($product, $attribute, $attributeSet)]; }