/** * Prepare product data. * * @param CatalogProductSimple $product * @param CatalogProductAttribute $attribute * @param CatalogAttributeSet $attributeSet * @return CatalogProductSimple */ protected function prepareProduct($product, $attribute, $attributeSet) { $data = ['attribute_set_id' => ['attribute_set' => $attributeSet], 'custom_attribute' => $attribute]; $data = array_merge($data, $product->getData()); return $this->fixtureFactory->createByCode('catalogProductSimple', ['data' => $data]); }
/** * Preparation of fixture data before comparing * * @param CatalogProductSimple $productSearch * @return array */ protected function prepareFixtureData(CatalogProductSimple $productSearch) { $compareData = []; foreach ($productSearch->getData() as $key => $value) { if ($key === 'price') { if (isset($value['price_from'])) { $compareData[$key][] = $value['price_from']; } if (isset($value['price_to'])) { $compareData[$key][] = $value['price_to']; } } else { $index = isset($this->placeholder[$key]) ? $this->placeholder[$key] : $key; $compareData[$index][] = $value; } } unset($compareData['url_key']); return $compareData; }
/** * Run mass update product simple entity test. * * @param CatalogProductSimple $initialProduct * @param CatalogProductSimple $product * @param string $configData * @return array */ public function test(CatalogProductSimple $initialProduct, CatalogProductSimple $product, $configData) { $this->configData = $configData; // Preconditions $initialProduct->persist(); $this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $configData])->run(); // Steps $this->productGrid->open(); $this->productGrid->getProductGrid()->updateAttributes([['sku' => $initialProduct->getSku()]]); $this->attributeMassActionPage->getAttributesBlockForm()->fill($product); $this->attributeMassActionPage->getFormPageActions()->save(); $data = array_merge($initialProduct->getData(), $product->getData()); $product = $this->objectManager->create('Magento\\Catalog\\Test\\Fixture\\CatalogProductSimple', ['data' => $data]); return ['category' => $initialProduct->getDataFieldConfig('category_ids')['source']->getCategories()[0], 'product' => $product]; }