Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractAssertItems.php
Go to the documentation of this file.
1 <?php
8 
11 use Magento\Mtf\Fixture\FixtureFactory;
13 
18 {
24  protected $sortKey = "::sku";
25 
31  protected $compareFields = [
32  'product',
33  'sku',
34  'qty',
35  ];
36 
45  protected function prepareOrderProducts(OrderInjectable $order, array $data = null, Cart $cart = null)
46  {
47  $productsData = [];
48  if ($cart === null) {
49  $cart['data']['items'] = ['products' => $order->getEntityId()['products']];
50  $fixtureFactory = $this->objectManager->create(FixtureFactory::class);
51  $cart = $fixtureFactory->createByCode('cart', $cart);
52  }
54  foreach ($cart->getItems() as $key => $item) {
55  if (isset($data[$key]['qty']) && $data[$key]['qty'] == 0) {
56  continue;
57  }
58  $productsData[] = [
59  'product' => $item->getData()['name'],
60  'sku' => $item->getData()['sku'],
61  'qty' => (isset($data[$key]['qty']))
62  ? $data[$key]['qty']
63  : $item->getData()['qty'],
64  ];
65  }
66 
67  return $this->sortDataByPath($productsData, $this->sortKey);
68  }
69 
76  protected function preparePageItems(array $itemsData)
77  {
78  foreach ($itemsData as $key => $itemData) {
79  $itemsData[$key] = array_intersect_key($itemData, array_flip($this->compareFields));
80  }
81  return $this->sortDataByPath($itemsData, $this->sortKey);
82  }
83 }
$productsData
Definition: products.php:19
$order
Definition: order.php:55