Questions tagged [blocks]

denotes questions about the `Block` classes.

Filter by
Sorted by
Tagged with
0
votes
1answer
13 views

How to get data from table in block magento2? Note: my model is in another module and i want to get data in another module.[frontend]

I have databse table with data.My model was created in one module and i want to get table data in another module's block class, so that i can render those data into my phtml. table name:form columns:...
0
votes
0answers
13 views

i want to make a home page 2 columns left bar, but it should not affect the banner

i want to make a home page with 2 columns left bar, but it should not affect the banne, i need the banner full width. or i need 2 column-left only for a particualr static block. i need sidebar like ...
0
votes
1answer
29 views

Using different background images for desktop/mobile display on blocks - widgets

I created a block and a widget in magento 2.4 page top to display as a banner promotion, but i want a different display for desktops and different for mobile. what i have tried: <div style="...
0
votes
1answer
31 views

Magento 2.4.2 : Move existing core block to child block

I am trying to move page.main.title to child block of my custom block on custom page. I have defined one block in my layout file with template assigned to it. I want to show page title in between the ...
0
votes
0answers
16 views

How to upload Video using wysiwyg editor in Magento 2

I want to add video in Content Block like upload video from my pc not youtube or vimeo. I want to add an option here to upload a video from my pc. And like used it on anywhere like other blocks are ...
0
votes
2answers
26 views

How to change the amount of products shown in related products programatically?

I want to display more than 4 products in the related products block. I've tried some solutions like overriding the core Related.php class and using methods: $this->_itemCollection->setPageLimit(...
1
vote
1answer
21 views

difference between the Block and UI_Component to Make grid and Form at admin side?

What is the Difference way to use of Block and ui_components to Make the Admin side grid and form and fields and elements in the form, can someone explain, which is better way to choose and Why ?
0
votes
1answer
31 views

How to call one block function to another block in same module

First Block: app\code\Zero\Storelocator\Block\view\Attributes.php function name : getLocationAttributes() Second Block: app\code\Zero\Storelocator\Block\Customerreview.php How to get the first ...
0
votes
1answer
17 views

Magento 2 which of the elements automatically render their children in layout Xml?

Which two elements automatically render their children in Xml? <block class=”\Magento\Framework\View\Element\AbstractBlock” name=”shop.info.details”/> <block class=”\Magento\Framework\View\...
0
votes
2answers
37 views

$block->getNameInLayout returns block's name but for configurable product returns alias

I'm trying to add a custom template just after ADD To Cart Button in product's page. In catalog_product_view.xml its defined as bellow: <block class="Magento\Catalog\Block\Product\View" ...
0
votes
0answers
10 views

Put a bloc between top.search and minicart

I want to put a bloc between top.search and minicart but it's don't work : <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
0
votes
0answers
23 views

Bug to configure a widget : impossible to select a block

I am currently working on an e-commerce website, running with Magento 2.4.0. I have to create a new widget, but at the end of the configuration, I have to select a block, which is impossible due to ...
0
votes
2answers
19 views

Invalid template file: 'Company_module::menubtn.phtml' in module: '' block's name: 'custom_menu'

I want display a phtml file in the header, i created a phtml file and called in the default.xml but it is giving invalid template file block's name, what should be give as a block name menubtn.phtml &...
0
votes
1answer
16 views

Magento 1.9 createBlock('catalog/product_list') to show specific only products

Here is my code which show products based on specific category echo $this->getLayout()->createBlock('catalog/product_list') ->setData('category_id', '25') ...
0
votes
1answer
13 views

Reporting on Blocks in Content Elements of 2.3.2

How would I set up reporting on Blocks that are set up in Content Elements of our Magento 2.3.2 website? These blocks contain advertising and I would like to see if customers click on them.
1
vote
2answers
76 views

Proper way to get $block->getChildHtml inside the custom phtml file

I want to add default wishlist sidebar section into my Magento_Theme template, Layout xml file: <referenceBlock name="header.panel"> <block class="Magento\...
1
vote
1answer
39 views

Adding PHP to a Magento Block or Magento Page

I am new to Magento and have been reading all of the answers on how to add PHP to a Magento block or page. Seems that just adding doesn't work. I have seen answers like this {{block type="core/...
0
votes
1answer
32 views

Magento 2 can't view blocks or pages in backend

I just did a copy of my live website to set up a dev website but now on my dev website when I try to view the pages or blocks I get a log of errors. 1 exception(s): Exception #0 (ReflectionException): ...
1
vote
2answers
51 views

How to call a controller function in a block?

Is it possible to call a controller function in a block, if yes, please define how can i achieve that.
0
votes
0answers
16 views

How to use 2 models in layout folder in xml that should show in inside view show.phtml file. Please tell how the controller is linked with block

How to use 2 models in layout folder in xml that should show in inside view show.phtml file. Please tell how the controller is linked with block. And how a layout file is linked with the controller ...
0
votes
0answers
103 views

How to call static block into graphql query in alpine js framework

enter code <div class="bg-container border-t border-b border-container"> <div class="container px-5 py-6 mx-auto flex items-center sm:flex-row flex-col" x-data=...
0
votes
3answers
28 views

Magento 2 - Get name of templates block from .phtml file

Is it possible to get the block name of the current template? For example I added a block to catalog_product_view.xml: <block class="Magento\Contact\Block\ContactForm" name="...
0
votes
2answers
48 views

Magento 2 how to show custom block before product.info.details and after media

Magento 2.3.5-p2 how to show custom block before product.info.details and after media ? <div class="product-info-main"></div> <div class="product media"></div&...
0
votes
3answers
51 views

Magento 2 - How to render a block inside another?

On the PDP I am trying to create a new block (product.info.main.inner) inside of product.info.main so I can pass arguments to it and then move all off the child blocks inside product.info.main.inner. ...
1
vote
0answers
18 views

How to access widget configuration options in Block class?

Although there's a similar question asked, it doesn't have an answer as the comment there refers to a question which has a comment that shows how to access the admin panel configuration parameters in ...
1
vote
1answer
81 views

magento 2 custom product grid not updating hidden values

Magento 2 custom product grid on the custom module not updating hidden values of It should be like this like category - AssignProducts.php <?php /** * Created By : RH */ namespace Social\Media\...
1
vote
1answer
33 views

Pass data to block file from ajax request

How do I pass data from the controller to my block file? Below is the code which I am using inside the controller. $this->_view->loadLayout(); $this->_view->getLayout() ...
0
votes
0answers
11 views

Add button to admin page with using block

I have created an admin page using block classes but I want to add an action button like grids. I know this can be done using UI component but for this task I am not using UI Component and its not ...
0
votes
1answer
31 views

Issue overwriting a third party extension?

I'm trying to overwrite only this file but I'm having no luck in it working, am I doing something wrong? vendor/mageplaza/module-lazy-loading/Plugin/Model/Template/Filter.php app/code/MySite/...
0
votes
1answer
29 views

Generate Random numbers for multiple block call

I am trying to implement custom flash toy for website. To do this I have created custom module. In custom module, I have created a block class. Block class contain the function to generate the Random ...
0
votes
1answer
29 views

How to add class for Reference Block Arguments in xml file?

I have created custom in link header, <referenceBlock name="header.links"> <block class="Magento\Framework\view\Element\Html\Link" name="custom-link" before=&...
0
votes
0answers
45 views

How to get custom table from data fetch by form id in magento 2.3.1

How to get custom table form table by form_id for custom table in magento 2.3.1? try this but it's not working custom table screen short: Vendor\Module\Block\Form.php <?php namespace Vendor\...
2
votes
1answer
42 views

main.CRITICAL: Class Company\Modulename\Block\Index does not exist

I'm creating a very simple module and I am missing something. The module page will not load, and I see these errors: [2020-12-11 15:51:21] main.CRITICAL: Class Company\Modulename\Block\Index does not ...
0
votes
0answers
26 views

How can i pass an object with it's value using DI?

I'm still new at Magento and im trying to work on something where I need to pass the product SKU from a file that has a function that retrieves the product SKU to another file with no such function, ...
0
votes
0answers
28 views

The block is not displaying after loading the page

Please help solve this puzzle. I'm created after plugin, after load category widget. The collection of items must be used in the js. The idea is to simply intercept the collection in the plugin, load ...
0
votes
0answers
44 views

layout sales_order_create_index.xml explain code please

vendor/magento/module-sales/view/adminhtml/layout/sales_order_create_index.xml There are two blocks name="coupons" and name="order_create_coupons_form" with classes Magento\Sales\...
0
votes
1answer
17 views

Product page modification for specific products

I would like to make some product modifcations; change qty position to move in the top, add total price (qte* unit_price) in /vendor/magento/module-catalog/view/base/templates/product/price/amount/...
0
votes
1answer
20 views

How to wrap .header.content?

I need to wrap .header.content in a . How can I do that using default.xml file? I think using something like that: <referenceBlock name="header-wrapper"> <...
0
votes
0answers
11 views

Accessing block from controller in magento2

I'm trying to use functions in \Magento\Swatches\Block\Product\Renderer\Listing\Configurable directly from my controller. Ive created an instance like this : $swatchInstance = $this->layoutFactory-&...
0
votes
2answers
32 views

How to create blocks as part of the theme?

Is it possible to create blocks as part of a theme, and have those blocks visible without actually having to create the block manually in the admin panel? I want to ship a theme with the blocks ...
0
votes
0answers
21 views

Creating a multi select box block in Magento 2?

This is my Magento 1 code, how would I rewrite this in Magento 2.3.3? I tried the exact way, but this is not working, I am getting a blank screen. Any ideas? $select = $this->getLayout()->...
0
votes
1answer
36 views

How to display static block on all pages

I wanted to display a static block with the identifer: popular_brands I created widget: But impossible anyway display static block before footer, etc. I try all this option with "footer" ...
0
votes
1answer
510 views

send Observer data to phtml file in Magento 2

I am trying to send Observer info into the block file. used the add to cart event as like below. app/code/Vendor/Module/etc/events.xml <?xml version="1.0"?> <config xmlns:xsi="...
1
vote
2answers
43 views

how to add custom phtml file in magento 2.3.1

how to add product.info referenceBlock add custom phtml in magento 2.3.1 but not added app/design/frontend/{Theme}/{name}/Magento_Catalog/layout/catalog_product_view.xml <referenceBlock name=...
0
votes
1answer
44 views

How to Get block 'head' description in Magento 2?

In magento 1.9 i can get the page head description like this in phtml: $this->getLayout()->getBlock('head')->getDescription() How can i achieve this in Magento 2 ?
0
votes
1answer
358 views

Search $block->getData('configProvider') in form.mini.phtml returns null after upgrade to 2.3.6

In 2.3.6, the following line was added to form.mini.phtml: $configProvider = $block->getData('configProvider'); Since the upgrade, this returns null and causes a fatal error due to this subsequent ...
0
votes
2answers
31 views

using customer session in block

I want to get customer id in block but the customer session returns null. from controller, i could get customer id. logger in block works well so the customer id is executed. vendor/Block/Config.php ...
0
votes
0answers
26 views

How to show the static block only for logged in customers globally?

I have created static block in admin panel and want to show that block only for logged in customers. I have tried it via creating the module and in template file I have written a condition to show the ...
1
vote
1answer
34 views

How to call block function in CMS page?

Version: Magento 2.4 EE I want to show the Recently Ordered Items Block in CMS page but when I call the block in page, the block is not displaying as expected and the page is empty. In CMS page, my ...
0
votes
0answers
30 views

Magento 2 - Load html of a template from PHP class

I have a php class where I am generating some HTML and returning it. private function _generateNote($expressRule) { if ($expressRule["hasNotAllowedCategories"]) { $note = "...

1
2 3 4 5
36