/** * Prepare product price from fixture. * * @param InjectableFixture $product * @return float */ protected function prepareFixturePrice(InjectableFixture $product) { /** @var CatalogProductSimple $product */ $customOptions = $product->getCustomOptions(); $checkoutData = $product->getCheckoutData(); $checkoutCustomOptions = isset($checkoutData['options']['custom_options']) ? $checkoutData['options']['custom_options'] : []; if (isset($checkoutData['cartItem'])) { $fixturePrice = $checkoutData['cartItem']['price']; } else { $fixturePrice = $product->getPrice(); $groupPrice = $product->getGroupPrice(); $specialPrice = $product->getSpecialPrice(); if ($groupPrice) { $groupPrice = reset($groupPrice); $fixturePrice = $groupPrice['price']; } if ($specialPrice) { $fixturePrice = $specialPrice; } foreach ($checkoutCustomOptions as $checkoutOption) { $attributeKey = str_replace('attribute_key_', '', $checkoutOption['title']); $optionKey = str_replace('option_key_', '', $checkoutOption['value']); $option = $customOptions[$attributeKey]['options'][$optionKey]; if ('Fixed' == $option['price_type']) { $fixturePrice += $option['price']; } else { $fixturePrice += $fixturePrice / 100 * $option['price']; } } } return $fixturePrice; }