/** * Prepare data. * * @param array $data * @param Items $itemsBlock * @return array */ protected function prepareData(array $data, Items $itemsBlock) { $fixtureData = []; foreach ($data as $product) { $checkoutData = $product->getCheckoutData(); $fixtureData[] = ['name' => $product->getName(), 'price' => number_format($this->getProductPrice($product), 2), 'checkout_data' => ['qty' => $this->productsIsConfigured && isset($checkoutData['qty']) ? $checkoutData['qty'] : 1]]; } $pageData = $itemsBlock->getProductsDataByFields($this->fields); $preparePageData = $this->arraySort($fixtureData, $pageData); return ['fixtureData' => $fixtureData, 'pageData' => $preparePageData]; }
/** * Prepare data * * @param array $data * @param Items $itemsBlock * @return array */ protected function prepareData(array $data, Items $itemsBlock) { $fixtureData = []; foreach ($data as $product) { $products = $product->getAssociated()['products']; foreach ($products as $key => $value) { $fixtureData[$key]['name'] = $value->getName(); $fixtureData[$key]['price'] = number_format($value->getPrice(), 2); } $options = $product->getCheckoutData()['options']; foreach ($options as $key => $option) { $fixtureData[$key]['checkout_data']['qty'] = $option['qty']; } } $pageData = $itemsBlock->getProductsDataByFields($this->fields); return ['fixtureData' => $fixtureData, 'pageData' => $pageData]; }