/** * Add products by SKU on backend. * * @param Customer $customer * @param array $orderOptions * @param string $cartBlock * @param string|null $products * @return array */ public function test(Customer $customer, array $orderOptions, $cartBlock, $products = null) { // Preconditions $products = $this->createProducts($products); $orderOptions = $this->prepareOrderOptions($products, $orderOptions); // Steps $this->orderIndex->open(); $this->orderIndex->getPageActionsBlock()->addNew(); $this->orderCreateIndex->getCustomerGrid()->selectCustomer($customer); $this->orderCreateIndex->getStoreBlock()->selectStoreView(); $orderCreateBlock = $this->orderCreateIndex->getAdvancedOrderCreateBlock(); $orderCreateBlock->getItemsBlock()->clickAddProductsBySku(); $orderCreateBlock->getAddToOrderBySkuBlock()->getOrderBySkuForm()->fillForm($orderOptions); $this->orderCreateIndex->getAdvancedOrderCreateBlock()->getAddToOrderBySkuBlock()->addToCart(); $filteredProducts = $this->filterProducts($products, $cartBlock); return ['products' => isset($filteredProducts['cart']) ? $filteredProducts['cart'] : [], 'requiredAttentionProducts' => isset($filteredProducts['required_attention']) ? $filteredProducts['required_attention'] : []]; }
/** * Create new order. * * @return void */ public function run() { $this->orderIndex->getPageActionsBlock()->addNew(); }