コード例 #1
0
 /**
  * Create product
  *
  * @param FixtureInterface $fixture [optional]
  * @return mixed|string
  */
 public function persist(FixtureInterface $fixture = null)
 {
     Factory::getApp()->magentoBackendLoginUser();
     $createProductPage = Factory::getPageFactory()->getCatalogProductNew();
     $createProductPage->open(['type' => $fixture->getDataConfig()['create_url_params']['type'], 'set' => $fixture->getDataConfig()['create_url_params']['set']]);
     $createProductPage->getProductForm()->fill($fixture);
     $createProductPage->getFormPageActions()->save();
     $createProductPage->getMessagesBlock()->waitSuccessMessage();
 }
コード例 #2
0
ファイル: Curl.php プロジェクト: andrewhowdencom/m2onk8s
 /**
  * Post request for creating simple product.
  *
  * @param FixtureInterface|null $fixture [optional]
  * @return array
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function persist(FixtureInterface $fixture = null)
 {
     $config = $fixture->getDataConfig();
     $prefix = isset($config['input_prefix']) ? $config['input_prefix'] : null;
     $data = $this->prepareData($fixture, $prefix);
     return $this->createProduct($data, $config);
 }
コード例 #3
0
 /**
  * Post request for creating simple product
  *
  * @param FixtureInterface $fixture [optional]
  * @return mixed|string
  * @throws \Exception
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function persist(FixtureInterface $fixture = null)
 {
     $config = $fixture->getDataConfig();
     $prefix = isset($config['input_prefix']) ? $config['input_prefix'] : null;
     // @todo remove "if" when fixtures refactored
     if ($fixture instanceof InjectableFixture) {
         $fields = $fixture->getData();
         if ($prefix) {
             $data[$prefix] = $fields;
         } else {
             $data = $fields;
         }
     } else {
         $data = $this->_prepareData($fixture->getData('fields'), $prefix);
     }
     if ($fixture->getData('category_id')) {
         $data['product']['category_ids'] = $fixture->getCategoryIds();
     }
     $url = $this->_getUrl($config);
     $curl = new BackendDecorator(new CurlTransport(), new Config());
     $curl->addOption(CURLOPT_HEADER, 1);
     $curl->write(CurlInterface::POST, $url, '1.0', [], $data);
     $response = $curl->read();
     $curl->close();
     if (!strpos($response, 'data-ui-id="messages-message-success"')) {
         throw new \Exception("Product creation by curl handler was not successful! Response: {$response}");
     }
     preg_match("~Location: [^\\s]*\\/id\\/(\\d+)~", $response, $matches);
     return isset($matches[1]) ? $matches[1] : null;
 }
コード例 #4
0
 /**
  * Assert that duplicated product is found by sku and has correct product type, product template,
  * product status disabled and out of stock
  *
  * @param FixtureInterface $product
  * @param CatalogProductIndex $productGrid
  * @return void
  */
 public function processAssert(FixtureInterface $product, CatalogProductIndex $productGrid)
 {
     $config = $product->getDataConfig();
     $filter = ['name' => $product->getName(), 'visibility' => $product->getVisibility(), 'status' => 'Disabled', 'sku' => $product->getSku() . '-1', 'type' => ucfirst($config['create_url_params']['type']) . ' Product', 'price_to' => number_format($product->getPrice(), 2)];
     $productGrid->open()->getProductGrid()->search($filter);
     $filter['price_to'] = '$' . $filter['price_to'];
     \PHPUnit_Framework_Assert::assertTrue($productGrid->getProductGrid()->isRowVisible($filter, false), 'Product duplicate is absent in Products grid.');
 }
コード例 #5
0
ファイル: Grid.php プロジェクト: QiuLihua83/magento-ee
 /**
  * Select order item.
  *
  * @param FixtureInterface $product
  * @reutrn void
  */
 public function selectItem(FixtureInterface $product)
 {
     /** @var CatalogProductSimple $product */
     $productConfig = $product->getDataConfig();
     if (isset($this->productsGrids[$productConfig['type_id']])) {
         $this->blockFactory->create($this->productsGrids[$productConfig['type_id']], ['element' => $this->_rootElement])->selectItem($product);
     } else {
         $this->searchAndSelect(['name' => $product->getName()]);
     }
 }
コード例 #6
0
ファイル: Grid.php プロジェクト: hientruong90/ee_14_installer
 /**
  * Select order item.
  *
  * @param FixtureInterface $product
  * @reutrn void
  */
 public function selectItem(FixtureInterface $product)
 {
     /** @var CatalogProductSimple $product */
     $productConfig = $product->getDataConfig();
     $productType = isset($productConfig['type_id']) ? ucfirst($productConfig['type_id']) : '';
     $productGridClass = 'Enterprise\\Rma\\Test\\Block\\Adminhtml\\Rma\\NewRma\\Tab\\Items\\Order\\' . $productType . 'Grid';
     if (class_exists($productGridClass)) {
         $productGrid = $this->blockFactory->create($productGridClass, ['element' => $this->_rootElement]);
         $productGrid->selectItem($product);
     } else {
         $this->searchAndSelect(['name' => $product->getName()]);
     }
 }
コード例 #7
0
ファイル: Cart.php プロジェクト: kidaa30/magento2-platformsh
 /**
  * Get cart item block
  *
  * @param FixtureInterface $product
  * @return CartItem
  */
 public function getCartItem(FixtureInterface $product)
 {
     $dataConfig = $product->getDataConfig();
     $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null;
     $cartItem = null;
     if ($this->hasRender($typeId)) {
         $cartItem = $this->callRender($typeId, 'getCartItem', ['product' => $product]);
     } else {
         $cartItemBlock = $this->_rootElement->find(sprintf($this->cartItemByProductName, $product->getName()), Locator::SELECTOR_XPATH);
         $cartItem = $this->blockFactory->create('Magento\\Weee\\Test\\Block\\Cart\\CartItem', ['element' => $cartItemBlock]);
     }
     return $cartItem;
 }
コード例 #8
0
 /**
  * Click on "Save" button
  *
  * @param FixtureInterface|null $product [optional]
  * @return void
  */
 public function save(FixtureInterface $product = null)
 {
     $typeId = null;
     if ($product) {
         $dataConfig = $product->getDataConfig();
         $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null;
     }
     if ($this->hasRender($typeId)) {
         $this->callRender($typeId, 'save', ['product' => $product]);
     } else {
         parent::save();
     }
 }
コード例 #9
0
 /**
  * Fill in the option specified for the product
  *
  * @param FixtureInterface $product
  * @return void
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function fillOptions(FixtureInterface $product)
 {
     $dataConfig = $product->getDataConfig();
     $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null;
     $checkoutData = null;
     /** @var CatalogProductSimple $product */
     if ($this->hasRender($typeId)) {
         $this->callRender($typeId, 'fillOptions', ['product' => $product]);
     }
     /** @var CatalogProductSimple $product */
     $checkoutData = $product->getCheckoutData();
     $checkoutCustomOptions = isset($checkoutData['options']['custom_options']) ? $checkoutData['options']['custom_options'] : [];
     $customOptions = $product->hasData('custom_options') ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() : [];
     $checkoutCustomOptions = $this->prepareCheckoutData($customOptions, $checkoutCustomOptions);
     $this->getCustomOptionsBlock()->fillCustomOptions($checkoutCustomOptions);
 }
コード例 #10
0
ファイル: ProductForm.php プロジェクト: Doability/magento2dev
 /**
  * Fill the product form.
  *
  * @param FixtureInterface $product
  * @param SimpleElement|null $element
  * @param FixtureInterface|null $category
  * @return $this
  * @throws \Exception
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function fill(FixtureInterface $product, SimpleElement $element = null, FixtureInterface $category = null)
 {
     $this->waitPageToLoad();
     $dataConfig = $product->getDataConfig();
     $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null;
     if ($this->hasRender($typeId)) {
         $renderArguments = ['product' => $product, 'element' => $element, 'category' => $category];
         $this->callRender($typeId, 'fill', $renderArguments);
     } else {
         $sections = $this->getFixtureFieldsByContainers($product);
         if ($category) {
             $sections['product-details']['category_ids']['value'] = $category->getName();
         }
         $this->fillContainers($sections, $element);
     }
     return $this;
 }
コード例 #11
0
ファイル: View.php プロジェクト: kidaa30/magento2-platformsh
 /**
  * Return product options.
  *
  * @param FixtureInterface $product
  * @return array
  */
 public function getOptions(FixtureInterface $product)
 {
     /** @var CatalogProductSimple $product */
     $dataConfig = $product->getDataConfig();
     $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null;
     return $this->hasRender($typeId) ? $this->callRender($typeId, 'getOptions', ['product' => $product]) : $this->getCustomOptionsBlock()->getOptions($product);
 }
コード例 #12
0
 /**
  * Get product type
  *
  * @return string
  */
 protected function getProductType()
 {
     $config = $this->product->getDataConfig();
     return ucfirst($config['type_id']) . ' Product';
 }
コード例 #13
0
ファイル: ProductForm.php プロジェクト: cewolf2002/magento
 /**
  * Get product type.
  *
  * @param FixtureInterface $product
  * @return string|null
  */
 protected function getProductType(FixtureInterface $product)
 {
     $dataConfig = $product->getDataConfig();
     return isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null;
 }
コード例 #14
0
 /**
  * Create and save product
  *
  * @param FixtureInterface $product
  * @return void
  */
 protected function createAndSaveProduct(FixtureInterface $product)
 {
     $dataConfig = $product->getDataConfig();
     $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null;
     $this->catalogProductIndex->open();
     $this->catalogProductIndex->getGridPageActionBlock()->addProduct($typeId);
     $this->catalogProductNew->getProductForm()->fill($product);
     $this->catalogProductNew->getFormPageActions()->save($product);
 }
コード例 #15
0
 /**
  * Fill the product form.
  *
  * @param FixtureInterface $product
  * @param SimpleElement|null $element [optional]
  * @param FixtureInterface|null $category [optional]
  * @return FormTabs
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function fill(FixtureInterface $product, SimpleElement $element = null, FixtureInterface $category = null)
 {
     $dataConfig = $product->getDataConfig();
     $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null;
     if ($this->hasRender($typeId)) {
         $renderArguments = ['product' => $product, 'element' => $element, 'category' => $category];
         $this->callRender($typeId, 'fill', $renderArguments);
     } else {
         $tabs = $this->getFieldsByTabs($product);
         if ($category) {
             $tabs['product-details']['category_ids']['value'] = $category->getName();
         }
         $this->showAdvancedSettings();
         $this->fillTabs($tabs, $element);
         if ($product->hasData('custom_attribute')) {
             $this->createCustomAttribute($product);
         }
     }
     return $this;
 }
コード例 #16
0
ファイル: Items.php プロジェクト: chucky515/Magento-CE-Mirror
 /**
  * Get module name from fixture.
  *
  * @param FixtureInterface $product
  * @return string
  */
 protected function getCartItemClass(FixtureInterface $product)
 {
     $typeId = $product->getDataConfig()['type_id'];
     return ObjectManager::getInstance()->create($this->itemRender[$typeId], ['product' => $product]);
 }
コード例 #17
0
 /**
  * POST request for creating downloadable product
  *
  * @param FixtureInterface $fixture [optional]
  * @return int id of created product
  */
 public function persist(FixtureInterface $fixture = null)
 {
     $config = $fixture->getDataConfig();
     $curl = new BackendDecorator(new CurlTransport(), new Config());
     $curl->addOption(CURLOPT_HEADER, 1);
     $curl->write(CurlInterface::POST, $this->getUrl($config), '1.0', [], $this->prepareData($fixture->getData('fields'), isset($config['input_prefix']) ? $config['input_prefix'] : null));
     $response = $curl->read();
     $curl->close();
     preg_match("~Location: [^\\s]*\\/id\\/(\\d+)~", $response, $matches);
     return $matches[1];
 }
コード例 #18
0
 /**
  * Post request for creating simple product.
  *
  * @param FixtureInterface|null $fixture [optional]
  * @return array
  */
 public function persist(FixtureInterface $fixture = null)
 {
     $config = $fixture->getDataConfig();
     $data = $this->prepareData($fixture);
     return $this->createProduct($data, $config);
 }