10 use Magento\Mtf\Config\DataInterface;
11 use Magento\Mtf\Fixture\FixtureInterface;
12 use Magento\Mtf\Handler\Curl as AbstractCurl;
13 use Magento\Mtf\System\Event\EventManagerInterface;
14 use Magento\Mtf\Util\Protocol\CurlInterface;
65 'include_in_menu' => [
70 'Static block and products' =>
'PRODUCTS_AND_PAGE',
71 'Static block only' =>
'PAGE',
72 'Products only' =>
'PRODUCTS',
78 'available_product_listing_config' => [
82 'custom_use_parent_settings' => [
86 'custom_apply_to_products' => [
91 '1 column' =>
'1column',
92 '2 columns with left bar' =>
'2columns-left',
93 '2 columns with right bar' =>
'2columns-right',
94 '3 columns' =>
'3columns',
105 'Position' =>
'position',
118 EventManagerInterface $eventManager,
135 $url = $_ENV[
'app_backend_url'] .
'catalog/category/save/store/0/parent/' .
$data[
'general'][
'parent_id'] .
'/';
137 $this->backendTransport->write(
$url,
$data);
138 $response = $this->backendTransport->read();
139 $this->backendTransport->close();
141 if (strpos(
$response,
'data-ui-id="messages-message-success"') ===
false) {
142 $this->_eventManager->dispatchEvent([
'curl_failed'], [
$response]);
143 throw new \Exception(
'Category creation by curl handler was not successful!');
146 preg_match(
'#http://.+/id/(\d+).+store/#m',
$response, $matches);
147 $id = isset($matches[1]) ? (int)$matches[1] :
null;
148 return [
'id' =>
$id];
160 $this->fields = [
'general' =>
$fixture->getData()];
166 $this->fields[
'general'] = $this->replaceMappingData($this->fields[
'general']);
177 $this->fields[
'general'][
'is_anchor'] = isset($this->fields[
'general'][
'is_anchor'])
178 ? $this->fields[
'general'][
'is_anchor']
181 $this->fields[
'general'][
'include_in_menu'] = isset($this->fields[
'general'][
'include_in_menu'])
182 ? $this->fields[
'general'][
'include_in_menu']
193 if ($this->fixture->hasData(
'landing_page')) {
194 $this->fields[
'general'][
'landing_page'] = $this->
getBlockId($this->fixture->getLandingPage());
199 $useConfig = array_diff($this->dataUseConfig, array_keys($this->fields[
'general']));
200 if (!empty($useConfig)) {
201 $this->fields[
'use_config'] = $useConfig;
203 unset($this->fields[
'general'][
'use_config']);
213 if (isset($this->fields[
'general'][
'available_sort_by'])) {
214 foreach ($this->fields[
'general'][
'available_sort_by'] as $key =>
$value) {
215 $this->fields[
'general'][
'available_sort_by'][$key] = $this->availableSortBy[
$value];
227 $categoryProducts = [];
228 $defaultPosition = 0;
230 if ($this->fixture->hasData(
'category_products')) {
231 $products = $this->fixture->getDataFieldConfig(
'category_products')[
'source']->getProducts();
233 $categoryProducts[
$product->getId()] = $defaultPosition;
237 $this->fields[
'category_products'] = json_encode($categoryProducts);
238 unset($this->fields[
'general'][
'category_products']);
249 $url = $_ENV[
'app_backend_url'] .
'catalog/category';
251 $curl->write(
$url, [], CurlInterface::GET);
254 preg_match(
'~\{"value":"(\d+)","label":"' . preg_quote($landingName) .
'"\}~',
$response, $matches);
255 $id = isset($matches[1]) ? (int)$matches[1] :
null;
prepareGeneralInformation()
prepareCategoryProducts()
prepareData(FixtureInterface $fixture)
persist(FixtureInterface $fixture=null)
__construct(DataInterface $configuration, EventManagerInterface $eventManager, BackendDecorator $backendTransport)