Description
Preconditions (*)
Magento 2.3.4
PHP 7.3
Steps to reproduce (*)
- Create new attribute using API
// End point: POST "/rest/default/V1/products/attributes";
// prepare the payload
$data = array(
"attribute" => array(
"is_wysiwyg_enabled" => false,
"is_html_allowed_on_front" => true,
"used_for_sort_by" => true,
"is_filterable" => true,
"is_filterable_in_search" => true,
"is_used_in_grid" => true,
"is_visible_in_grid" => true,
"is_filterable_in_grid" => true,
"position" => 0,
"is_searchable" => true,
"is_visible_in_advanced_search" => true,
"is_comparable" => true,
"is_used_for_promo_rules" => false,
"is_visible_on_front" => true,
"used_in_product_listing" => true,
"is_visible" => true,
"attribute_code" => "test_api",
"frontend_input" => "swatch_text",
"entity_type_id" => "4",
"is_required" => true,
"is_user_defined" => true,
"default_frontend_label" => "test_api2",
"frontend_labels" => [
array(
"store_id" => 0,
"label" => "test_api3"
)
],
"backend_type" => "int",
"is_unique" => false,
"is_required" => false
)
);
$payload = json_encode($data);
// make the call
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json' , $auth ));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
- Log in to Admin panel, go to Stores/Attributes/Attributes Set
- Add the newly created attrbute to the default attribute set
- Go to product page and click ADD PRODUCT
Expected result (*)
Product creation page should display normally
Actual result (*)
Error 500
Nginx logs below:
2020/02/12 04:45:19 [error] 1023#1023: *46116 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught TypeError: Argument 2 passed to Magento\Framework\View\Element\UiComponentFactory::argumentsResolver() must be of the type array, null given, called in /opt/magento/public_html/vendor/magento/framework/View/Element/UiComponentFactory.php on line 222 and defined in /opt/magento/public_html/vendor/magento/framework/View/Element/UiComponentFactory.php:174
Stack trace:
#0 /www/vendor/magento/framework/View/Element/UiComponentFactory.php(222): Magento\Framework\View\Element\UiComponentFactory->argumentsResolver('test_api', NULL)
#1 /www/vendor/magento/module-ui/Component/Form/Field.php(85): Magento\Framework\View\Element\UiComponentFactory->create('test_api', 'swatch_text', Array)
#2 /www/vendor/magento/framework/View/Layout/Generator/UiComponent.php(164): Magento\Ui\Component\Form\Field->prepare()
#3 /www/vendor/magento/framework/View/Layout/Generator/UiComponent.php(161): Magento\Fr" while reading response header from upstream, client: 127.0.0.1, server: example.com, request: "GET /admin_xxx/catalog/product/new/set/4/type/simple/key/zzzzzzzzzzz/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.3-fpm-magento.sock:", host: "example.com", referrer: "https://example.com/admin_xxx/catalog/product/index/key/yyyyyyyyyy/"