Hot answers tagged

15

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, "multipleCollapsible": true}}'> <div data-role="collapsible"> <div data-role="trigger"> <span>Title 1</span> ...


12

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.phtml"}} and <?php echo $this->getLayout()->createBlock("Magento\Catalog\Block\Product\Widget\NewWidget")->setDisplayType("all_products")->...


11

Its not pretty, but of course you can create a widget instance programmatically, for example in a setup script: $widgetParameters = array( 'param1' => 'This is some value from the widget form, 'param2' => 'Some/other/value', 'param2_2' => 'Rly?', 'template' => 'this/is/the/template.phtml' ); $instance = Mage::getModel('widget/...


11

Try following way. <script> require( [ 'jquery', 'Magento_Ui/js/modal/modal' ], function( $, modal ) { var options = { type: 'popup', responsive: true, innerScroll: true, title: 'popup modal title'...


9

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 your etc dir. The key is, not to use the widget.xsd (there are many fields required that you do not need for extending) but the widget_file.xsd. Here is an ...


8

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" xsi:type="select" visible="true"> <label translate="true">Full Width</label> <options> <option name="yes" value="1" ...


7

Custom attribute with wysiwyg cannot be simply outputted. If it contains cms directives {{media url="wysiwyg/images_2_.jpg"}}, it should be preprocessed with catalog/output helper. <?php $product = $this->getProduct(); $attribute = $product->getYourAttribute(); $attributeName = 'your_attribute_name'; echo $this->helper('catalog/...


7

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 Mage_Adminhtml_Block_Widget_Grid_Container { public function __construct() { // The blockGroup must match the first half of how we call the block, and controller matches the second half ...


6

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::product/widget/content/grid.phtml" }}


6

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 parameters look like. For example, I created the widget with the condition "category = 4", showing five products: {{widget type="Magento\CatalogWidget\Block\...


5

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 magento module. My createBlock() strings ebuynow_ebnreports/adminhtml_shipments_report were specifying the grid container, when one of them should have been ...


5

getChildHtml() is used to call the child block inside a file corresponding to parent block. i.e. if you are in a phtml file (say app/design/frontend/default/default/template/catalog/category/view.phtml), it will be first declared in app/design/frontend/default/default/layout/catalog.xml like following: <block type="catalog/category_view" name="category....


5

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 allows a developer to package up a number of different RequireJS modules as KnockoutJS view model constructors, (with associated "remote" Knockout.js templates), ...


5

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 >> insert widget >> select catalog product list from widget type >> add title >> select category in condition field (click on + icon) >> insert widget >> save this ...


5

Create requirejs-config var config = { map: { '*': { yourWidgetName: 'NameSpace_ModuleName/js/yourwidgetfile', } }, }; Define you widget following convention define([ 'jquery', 'jquery/ui' ], function($) { "use strict"; $.widget('namespace.yourWidgetName', { // Logicial code // Optional ...


5

Try like this TBF_Cupom_Block_Adminhtml_Gerados_Index extends Mage_Adminhtml_Block_Widget_Form_Container { public function __construct() { ..... $this->_removeButton('add'); } } Note: _removeButton() is not in Mage_Adminhtml_Block_Widget_Grid it is in Mage_Adminhtml_Block_Widget_Form_Container . call proper extends or proper class need to call....


4

There's a widget for that! In your CMS page, {{widget type="catalog/product_widget_link" anchor_text="[Optional: CUSTOM LINK TEXT]" template="catalog/product/widget/link/link_block.phtml" id_path="product/223552"}} Then customize app/design/frontend/base/default/template/catalog/product/widget/link/link_block.phtml. I use ...


4

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/catalog_product_widget_chooser</type> ... </helper_block> This leads us to class Mage_Adminhtml_Block_Catalog_Product_Widget_Chooser where you can see they define some JS ...


4

If I remember correctly multiselect values are stored comma separated. Have you tried <value>opt1,opt2</value> ?


4

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 new to magento and i tried it. It worked for me. {{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/...


4

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 with Home Page Block. Now go to Content -> Blocks and find static block with title is "Home Page Block" to edit. You can customize content from here. ...


4

This works for me : <div data-mage-init='{"accordion":{"openedState": "active", "collapsible": true, "active": false, "multipleCollapsible": false}}'> <div data-role="collapsible"> <div data-role="trigger"> Title 1 </div> </div> <div data-role="content"> <p> ...


4

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 front page, with caching disabled. The 'Add to Cart' button wouldn't function as expected. Enabled all Magento2 caching options, and the problem was ...


4

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 constructor: /** * Example constructor. * @param \Magento\Cms\Model\Template\FilterProvider $filterProvider * @param \Magento\Catalog\Helper\Output $...


4

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 JS to add support for the product chooser parameter. In a custom module, add these files: {module_dir}/view/adminhtml/web/requirejs-config.js var config = { ...


4

I have created something similar using following code. app/code/Anshu/Bestsellerwidget/registration.php <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Anshu_Bestsellerwidget', __DIR__ ); app/code/Anshu/Bestsellerwidget/etc/module.xml <?xml version="1.0"?> &...


3

I know this is old but I stumbled on the same problem and here's a solution : <depends> <order_status> <values> <value1>processing</value1> <value2>processed_ogone</value2> </values> ...


3

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's important that the block class extends Mage_Core_Block_Template and implements Mage_Widget_Block_Interface. Finally in that block class you could set the ...


3

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 loads the hidden field that is used to store the value of the item as a reference and the using up it works up the dom to find the td that is should show or hide....


3

Getting my_field_name will return you raw content from the database. You have to pass it through CMS processor: echo Mage::helper('cms')->getBlockTemplateProcessor()->filter($myobject->getData('my_field_name'));


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