29 private $sequenceValues = [
30 'sequence_product_bundle_option' =>
null,
31 'sequence_product_bundle_selection' => null
37 private $productGeneratorFactory;
49 ProductGeneratorFactory $productGeneratorFactory,
52 $this->productGeneratorFactory = $productGeneratorFactory;
55 ResourceConnection::class
71 $this->productGeneratorFactory->create([
73 'catalog_product_bundle_option' => [
75 'handler' =>
function (
$productId, $entityNumber, $fixture, $binds) {
76 foreach ($binds as &$bind) {
77 $bind[
'option_id'] = $this->generateOptionId(
89 'sequence_product_bundle_option' => [
91 'handler' =>
function (
$productId, $entityNumber, $fixture, $binds) {
92 foreach ($binds as &$bind) {
93 $bind[
'sequence_value'] = $this->generateSequenceId(
94 'sequence_product_bundle_option' 101 'catalog_product_bundle_option_value' => [
103 'handler' =>
function (
$productId, $entityNumber, $fixture, $binds) {
104 foreach ($binds as &$bind) {
105 $bind[
'option_id'] = $this->generateOptionId(
117 'catalog_product_bundle_selection' => [
119 'handler' =>
function (
$productId, $entityNumber, $fixture, $binds) {
120 foreach ($binds as &$bind) {
121 $bind[
'selection_id'] = $this->generateSelectionId(
123 $bind[
'selection_id'],
129 $bind[
'option_id'] = $this->generateOptionId(
135 $bind[
'product_id'] = $this->generateSimpleProductId(
141 $bind[
'selection_price_type'] = $fixture[
'priceType']($bind[
'product_id']);
142 $bind[
'selection_price_value'] = $fixture[
'price']($bind[
'product_id']);
148 'sequence_product_bundle_selection' => [
150 'handler' =>
function (
$productId, $entityNumber, $fixture, $binds) {
151 foreach ($binds as &$bind) {
152 $bind[
'sequence_value'] = $this->generateSequenceId(
153 'sequence_product_bundle_selection' 160 'catalog_product_relation' => [
162 'handler' =>
function (
$productId, $entityNumber, $fixture, $binds) {
163 foreach ($binds as &$bind) {
165 $bind[
'child_id'] = $this->generateSimpleProductId(
187 private function generateOptionId($entityNumber, $originalOptionId, array $fixture)
189 if ($originalOptionId) {
190 return $fixture[
'_bundle_options'] * ($entityNumber + 1) + $originalOptionId;
193 return $originalOptionId;
205 private function generateSelectionId($entityNumber, $originalSelectionId, array $fixture)
207 if ($originalSelectionId) {
208 $selectionsPerProduct = $fixture[
'_bundle_products_per_option'] * $fixture[
'_bundle_options'];
210 return $selectionsPerProduct * ($entityNumber + 1) + $originalSelectionId;
213 return $originalSelectionId;
223 private function generateSequenceId(
$tableName)
231 'MAX(`sequence_value`)' 247 private function generateSimpleProductId($previousProductId, $entityNumber, array $fixture)
249 return $previousProductId +
250 $entityNumber * $fixture[
'_bundle_products_per_option'] * $fixture[
'_bundle_options'];
__construct(ProductGeneratorFactory $productGeneratorFactory, ResourceConnection $resource=null)
generate($products, $fixtureMap)
const SKIP_ENTITY_ID_BINDING