Hot answers tagged

20 votes

Magento 2 - How to create FAQ page with accordion

It is possible. If you want to use data-mage-init Then you do it like this: <div id="element" data-mage-init='{"accordion":{"openedState": "active", "collapsible": true, "active": false, "...
user avatar
  • 421
14 votes

Magento2: How to override widget template

you can extend the widget in your module. To do that your module has to depend on the module where the original widget is defined (see sequence in the module.xml). Then you create a widget.xml in ...
user avatar
14 votes
Accepted

Magento 2: Call a Widget in a .phtml file

For Display Type = All Product Widget {{widget type="Magento\Catalog\Block\Product\Widget\NewWidget" display_type="all_products" products_count="5" template="product/widget/new/content/new_grid....
user avatar
11 votes
Accepted

Magento 2 Modal Widget

Try following way. <script> require( [ 'jquery', 'Magento_Ui/js/modal/modal' ], function( $, modal ) { ...
user avatar
  • 34.3k
10 votes
Accepted

Magento 2: How to put default value in yes/no field of widget.xml in magento 2?

If default values are not working for YesNo (I don't have time to dig) then you could always cheese the system for the time being and try to find a cleaner solution: <parameter name="chart_layout"...
user avatar
8 votes

Magento2: How to override widget template

You can replace the grid.phtml where you call the widget {{widget type="Magento\CatalogWidget\Block\Product\ProductsList" title="Our Products" products_count="8" template="Namespace_Modulename::...
user avatar
7 votes
Accepted

Component vs Widget

The widget can be initialized with a few lines of JS, where as the component requires many lines of XML and still uses the widget. So why would anyone use the XML method? The UI component system ...
user avatar
  • 43.7k
7 votes
Accepted

How to call widget with products of specific category in ".phtml" file?

There is a widget for arbitrary product lists (as mentioned by @Nits). If you insert the widget on any CMS page or block and turn off the WYSIWYG editor ("Hide editor" button), you can see how the ...
user avatar
7 votes

How to remove ‘Add New’ button from Admin Grid in Magento 1.9?

Renate, if you are following the tutorial, then you'll need to add the code suggested by Rama to this section <?php class Foo_Bar_Block_Adminhtml_Baz extends ...
user avatar
  • 71
6 votes

How to call widget with products of specific category in ".phtml" file?

You can do it via static-block: 1) add static block with widget of catalog product list and add category id in widget condition. (content menu >> Blocks >> add new >> click on show/hid button >> ...
user avatar
  • 2,356
6 votes

Add javascript in custom widget

Create requirejs-config var config = { map: { '*': { yourWidgetName: 'NameSpace_ModuleName/js/yourwidgetfile', } }, }; Define you widget following convention ...
user avatar
  • 3,153
5 votes

Why does the 'Container Widget Header' appear twice in my grid in my ajax grid?

The problem was caused by the string used in one of the createBlock() calls. To wit, Magento grids consist of a Grid Container class, and a Grid class, which both live in the Block directory of a ...
user avatar
5 votes
Accepted

How to use tabs widget in magento2

You have error on the page because you miss your tabs widget in dependencies list (at list if you want to use Magento's tabs widget). Correct: require([ 'jquery', 'mage/tabs' ], function($){ ...
user avatar
  • 350
5 votes

How to remove ‘Add New’ button from Admin Grid in Magento 1.9?

Try like this TBF_Cupom_Block_Adminhtml_Gerados_Index extends Mage_Adminhtml_Block_Widget_Form_Container { public function __construct() { ..... $this->_removeButton('add'); } } Note: ...
user avatar
5 votes
Accepted

How to pass a variable to a JS widget in Magento 2

You can get the values passed from phtml to widget in any function using below code, this.options.ajaxShipmentUrl
user avatar
  • 1,706
4 votes
Accepted

Default values of a multiselect input in widget options using widget.xml

If I remember correctly multiselect values are stored comma separated. Have you tried <value>opt1,opt2</value> ?
user avatar
  • 37.4k
4 votes
Accepted

Can we make Widget Options validaton in magento?

Take a look at how Magento defined a helper block in the Mage_Catalog module. In their widget.xml they define the helper block: <helper_block> <type>adminhtml/...
user avatar
4 votes
Accepted

How can I customize the widget on the homepage on Magento2 Luma theme?

Luma theme homepage content comes from widget. First of All, go to Admin panel, Content -> Widgets Now click on Home Page widget. You can check it using widget option tab, You have display Block ...
user avatar
4 votes

Newest Product Widget Not Showing Correct Products

Date also plays an important role. While inserting the product details. You give recent date and you paste this code in the home page By going to cms and manage pages of Magento admin panel. I am ...
user avatar
4 votes

Magento 2 - How to create FAQ page with accordion

This works for me : <div data-mage-init='{"accordion":{"openedState": "active", "collapsible": true, "active": false, "multipleCollapsible": false}}'> <div data-role="collapsible"> ...
user avatar
4 votes
Accepted

Magento2 Add to Cart from homepage not working

The solution (for no clarified reason) was to enable all Magento caching options. This solved the issue for me. Tested this again in a new install: Fresh Luma templated with new product widget on the ...
user avatar
  • 311
4 votes
Accepted

How to render widgets in product and category description in Magento 2?

Instead of instantiating the object manager and filterprovider etc. in your template, consider this: In your block class (Vendor\Module\Block\Widget\CustomWidget) include the dependencies in your ...
user avatar
  • 11.6k
4 votes
Accepted

Magento 2 : </depends> is Not Working in Widget.xml

The problem is that the JS that handles the show/hide functionality of dependency elements doesn't find anything in the case of xsi:type="block" fields. One way to get around this is to override the ...
user avatar
  • 8,774
4 votes

Magent2 Modal Widget - change width and height

You can use 'modalClass' option to set a custom css class to your modal popup und define width in the css: .my-custom-class .modal-inner-wrap { width: 600px; }
user avatar
  • 397
4 votes
Accepted

Magento 2: insert a "Bestsellers" widget via the Magento admin

I have created something similar using following code. app/code/Anshu/Bestsellerwidget/registration.php <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\...
user avatar
  • 8,598
4 votes
Accepted

Magento 2 decode widget code in category description

you need to pass the content of the description inside a function before the display. This filterProvider will replace the widget code inside the content of the description. public function ...
user avatar
  • 539
4 votes
Accepted

Magento 2: add magento widget button on product WYSIWYG editors

Here’s an example on how to do it for the Description field. You can use it for other WYSIWYG fields in the product edit page (just modify the condition for the IF in step number 2 and add the filter ...
user avatar
3 votes

Calling a template from within a widget

In the widget.xml you define with the typeattribute the block class of the widget. For example type="catalog/category_widget_link"refers to the block class Mage_Catalog_Block_Category_Widget_Link. It'...
user avatar
  • 165
3 votes

Widget dependency doesn't work for chooser fields

The problem is that you cannot use depends on widget items that are of type chooser :( In the file js/mage/adminhtml/form.js it processes the changes on widgets in the function trackChange. Here is ...
user avatar
3 votes

Magento 2 - How to create FAQ page with accordion

I think you are having an issue with data-mage-init when saving or edit the content of the CMS page back. You can use accordion in CMS page by adding accordion js to your custom theme. Add accordion ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible