/** * Loop through products and create instances of ProductRow, and add them to the bundle * * @param Bundle $bundle * * @param array $data */ private function _addProducts(Bundle $bundle, array $data) { foreach ($data[Form\BundleForm::PRODUCT] as $product) { $this->_validateProductData($product); $options = !empty($product[Form\BundleProductForm::OPTION_NAME]) && !empty($product[Form\BundleProductForm::OPTION_VALUE]) ? [$product[Form\BundleProductForm::OPTION_NAME] => $product[Form\BundleProductForm::OPTION_VALUE]] : []; $row = new ProductRow($product[Form\BundleProductForm::PRODUCT], $options, $product[Form\BundleProductForm::QUANTITY]); $bundle->addProductRow($row); } }