/** * Prepare POST data for creating product request. * * @param FixtureInterface $fixture * @param string|null $prefix [optional] * @return array */ protected function prepareData(FixtureInterface $fixture, $prefix = null) { $data = parent::prepareData($fixture, $prefix); if (isset($data[$prefix]['giftcard_amounts'])) { foreach ($data[$prefix]['giftcard_amounts'] as $key => $amounts) { if (!isset($amounts['website_id'])) { $data[$prefix]['giftcard_amounts'][$key]['website_id'] = 0; } } } return $data; }
/** * Prepare POST data for creating product request. * * @param FixtureInterface $fixture * @param string|null $prefix [optional] * @return array */ protected function prepareData(FixtureInterface $fixture, $prefix = null) { $data = parent::prepareData($fixture, null); $assignedProducts = []; if (!empty($data['associated'])) { $assignedProducts = $data['associated']; unset($data['associated']); } $data = $prefix ? [$prefix => $data] : $data; $links = ''; $fKey = md5('associated'); foreach ($assignedProducts as $key => $item) { $links .= $item['id'] . '=' . $fKey . '&'; } $data['links']['grouped'] = $links; return $data; }
/** * Prepare POST data for creating product request. * * @param FixtureInterface $fixture * @param string|null $prefix [optional] * @return array */ protected function prepareData(FixtureInterface $fixture, $prefix = null) { $originalData = parent::prepareData($fixture, $prefix); $downloadableData = []; $data = $prefix == null ? $originalData : $originalData[$prefix]; foreach ($this->downloadableTypes as $type => $fields) { if (!empty($data['downloadable_' . $type])) { $downloadableTypeData = $this->{'prepare' . ucfirst($type) . 'Data'}($data['downloadable_' . $type]); $data = array_merge_recursive($data, array_intersect_key($downloadableTypeData, array_flip($fields))); $downloadableData = array_merge_recursive($downloadableData, $downloadableTypeData); unset($downloadableTypeData['downloadable']); if ($prefix == null) { $originalData = array_merge($originalData, $downloadableTypeData); } else { $originalData[$prefix] = array_merge($originalData[$prefix], $downloadableTypeData); } } } $data = array_merge_recursive($originalData, $downloadableData); return $this->replaceMappingData($data); }
/** * Parse response. * * @param string $response * @return array */ protected function parseResponse($response) { $result = parent::parseResponse($response); return array_replace_recursive($result, $this->parseResponseSelections($result['id'])); }
/** * Prepare config data. * * @param InjectableFixture $product * @return array */ protected function prepareConfig(InjectableFixture $product) { $config = parent::prepareConfig($product); $config['create_url_params']['set'] = $product->getDataFieldConfig('configurable_options')['source']->getAttributeSet()->getAttributeSetId(); return $config; }