Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
new_widget.php
Go to the documentation of this file.
1 <?php
9  ->get(\Magento\Widget\Model\ResourceModel\Widget\Instance::class);
10 
12  ->get(\Magento\Widget\Model\Widget\Instance::class);
13 
14 // Set default theme as work ground for MAGETWO-63643
17  \Magento\Framework\View\Design\ThemeInterface::class
18 );
19 $theme->load('Magento/luma', 'theme_path');
20 
21 $model->setData(
22  [
23  'instance_type' => 'Magento\\Widget\\NewSampleWidget',
24  'theme_id' => $theme->getId(),
25  'title' => 'New Sample widget title',
26  'store_ids' => [
27  0 => '0',
28  ],
29  'widget_parameters' => [
30  'block_id' => '2',
31  ],
32  'sort_order' => '0',
33  'page_groups' => [],
34  'instance_code' => 'new_sample_widget',
35  ]
36 );
37 
38 $resourceModel->save($model);
$theme
Definition: new_widget.php:16
$model
Definition: new_widget.php:11
$resourceModel
Definition: new_widget.php:8