Questions tagged [blocks]

denotes questions about the `Block` classes.

Filter by
Sorted by
Tagged with
1 vote
2 answers
52 views

Magento 2 : How to create a non cacheable block

How Should I create a block without cache? Can anyone help?
Erik Kis's user avatar
0 votes
1 answer
57 views

Magento Custom Module Directory Help

Old user, Noob question! I have a module which is successfully "trying" to overide the sidebar.html block using the below code. var config = { "map": { "*": { ...
UK_Rogue's user avatar
0 votes
2 answers
152 views

Not able to access Customer Session via custom module in Magento 2

I'm not able to access the customer session in my custom module. However, when I'm navigating my custom action to salesrep/index/account I'm able to get the customer session. But when I'm navigating ...
Bojjaiah's user avatar
  • 4,002
1 vote
1 answer
82 views

How to remove block and block arguments in other XML layout magento 2

<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/...
Keval Chauhan's user avatar
0 votes
0 answers
18 views

Arguments shared between multiple instances of same block

I have created a custom block and tried to insert it multiple times in the same page: <block class="MyCompany\MyModule\Block\Producttabs\CategoryProducts" name="category.products....
zekia's user avatar
  • 620
1 vote
1 answer
41 views

Hi, I am new to magento. I am trying to place a CSS/javascript popup in the Products/Specification page, data from the static blocks

I am trying to place a CSS/Javascript popup onhover in the Products/Specification Section. Please refer the image. Onhover on the yellow circles. I have created some static blocks, which I want to ...
Biju's user avatar
  • 11
0 votes
0 answers
39 views

How to add simple php or java function result into page or block?

How to add simple php or java function result into page or block using the page builder? If not possible please advise on other ways. I'm new with Magento. I am writing a description of services ...
Mikauskas's user avatar
0 votes
1 answer
36 views

How to add category select in admin block page without UI component?

I am trying to add category selector in my block page without UI component. This is my block file. <?php namespace Uedakanamono\BannerSlider\Block\Adminhtml\Banner\Edit\Tab; use Magento\...
Malcom's user avatar
  • 21
0 votes
1 answer
25 views

Need a block to cache its result regardless if it called from the controller or the template

I have a block with a function getParts() which is called from a template. This function does a bunch of queries and returns an array of data. I need to make it so if it does not return any data, a ...
Nick's user avatar
  • 121
0 votes
0 answers
39 views

Child block is not loaded when the main block is called in a CMS page

I made a custom module block with the following layout: <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:...
mugnozzo's user avatar
  • 103
0 votes
0 answers
378 views

Close window popup after successfully submit form and refresh background form

I've added window model popup in block grid using add coulmnn method. this popup is loaded when admin user click on action column. this popup window render as below approch. $this->getColumn()->...
user73267's user avatar
  • 183
0 votes
1 answer
275 views

How to add an element under each product name on category pages?

How to add a subtitle / simple HTML element under each product name on a category page list? I've tried various solutions via adding referenceContainers to the catalog_category_view.xml in my module ...
breakworm's user avatar
0 votes
0 answers
32 views

Magento 2: Blocks missing identities

When working with Full Page Cache and Varnish, the blocks are suppose to pass an array on the function afterGetOutput, by using the function $block->getIdentities(). These arrays are then merged ...
archigrafix's user avatar
0 votes
1 answer
24 views

How do I create a Magento block that has input fields for to store values in variables?

My code for displaying rotating messages is currently hardcoded and I have to go in and update the messages manually. I want to replace this with a new block in magento so other people can just go ...
Alyx's user avatar
  • 1
0 votes
0 answers
106 views

Magento 2 Footer does not update

I am working on a problem with updating the content of the footer in Magento (Adobe Commerce ver. 2.4.5-p1). I am rather new to working with Magento and appreciate any help. A few days ago, my ...
danschdev's user avatar
1 vote
0 answers
87 views

Change price label from MYR to RM in Magento 2

In magento 2.4.4p2 commerce I am trying to change the pricing label from MYR to RM But I am not able to found ways to change it, I am able to find this source code which purpose is to show the ...
Mohd Farhan Bin Ramli's user avatar
0 votes
1 answer
404 views

How to call a block function from another block or template

At the moment I am trying to call a function that is in another block that I am writing from. I have tried through the __constructor() to pass the other block but this has not worked and using the ...
Andres Chaves's user avatar
0 votes
1 answer
592 views

Save custom frontend form data to database magento 2.4.5

I have created custom form on frontend and now on submit click I want to save filled data to database. module.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/...
Rakhi Prajapati's user avatar
0 votes
1 answer
121 views

Block that doesn't explicitly declare template?

I recently followed a tutorial to add a custom fee to the checkout summary of my Magento store and after getting everything working, I realized that the block I created didn't need to have an ...
A. Andersen's user avatar
0 votes
1 answer
792 views

Get cart items in Magento 2.4 blocks

I'm trying to get access to all items in the shopping cart in a block, but I can't seem to get them. If I try the code below to construct and $items = $this->_cart->getQuote()->...
Teun K's user avatar
  • 23
0 votes
2 answers
137 views

Calling magento block returning false

This probably easy and I'm forgetting something but... product.price.final is a default xml block of magento why does it always returns false when I call it on my custom phtml. <div> <?= $...
IndexError's user avatar
0 votes
1 answer
80 views

Custom block is not showed in header.panel

Stumbled on this issue: I need to add a block which switches between Web-pages in a DropDown form. I am using a custom theme here. Block must be located at this side But the problem is, that when I ...
Mykola Kikets's user avatar
0 votes
1 answer
509 views

Using a data patch to add the block into cms page

my task sounds like : "Using a data patch to add the block into cms page" i have data patch cms block class CmcBlock implements DataPatchInterface { const CMC_BLOCK = 'first_cmc_block';...
esca7a's user avatar
  • 21
0 votes
2 answers
81 views

Unable to display product name in catalog_product_view.xml

I am new at Magento, I would like to render the product name to catalog_product_view.xml (product page) from a custom phtml but it didn't work. May I know where did I go wrong? Thanks! app/code/...
hill2011's user avatar
0 votes
1 answer
586 views

Magento 2 : Disable Caching for the Block or cacheable false

I have tried to get update value without caching block. I have tried all below code,but they are not work. public function getCacheLifetime() { return null; } $this->addData([ '...
Jigs Parmar's user avatar
  • 2,438
2 votes
3 answers
1k views

best practice for get a block by id in *.phtml template in 2022 year?

Can you help me figure out which best practices to use for get block template by id in phtml file? thanks everyone if you need some info please send comment okay, try it: i created a block in admin ...
esca7a's user avatar
  • 21
1 vote
0 answers
134 views

List of custom variables that can be accessed inside a static block

What I want to do is inject variables into static blocks. I know this can be achieved in System -> Custom Variables but it wouldn't be any quicker than opening up every static block to change the ...
SilkSpin's user avatar
  • 192
0 votes
2 answers
293 views

Cannot insert custom block into 'product.price.final' in XML

Here is my catalog_product_view.xml: I want to insert one CustomBlock to this final price block, so i can use getChildHtml() to call in template final_price.phtml, but it does not work so far, why ? &...
Rita555-Simon's user avatar
1 vote
1 answer
109 views

CSS put in block not reflecting in magento 2

in magento 2.3.5p2 In Admin Panel Content > Elements > Blocks a Block has been created to showcase a list of products for promotion The content of the block is as below <img src="{{media ...
Mohd Farhan Bin Ramli's user avatar
1 vote
2 answers
3k views

How to pass argument from layout to block and how it works Magento 2?

I just wanted to know how to pass argumnet from layout to block and how its work and how its value pass in $data? Can anyone explain it deeply
Mark's user avatar
  • 63
1 vote
2 answers
1k views

Trying to get viewModel in phtml

I'm trying to get viewModel in two areas inside phtml. I'm getting an error (Fatal Error: 'Uncaught Error: Call to a member function getviewmodelText() on null). My code for ViewModel is : Phtml file :...
Mahmood Rehman's user avatar
1 vote
1 answer
117 views

is it possible to extend the block class in model

Is it possible to extend block class in model? if so, how to do it. please provide me with example. I have inherited model a class from model and i want to inherits class in block using the class i ...
Bayzel's user avatar
  • 187
0 votes
1 answer
34 views

How to get Current Product Id in which the Block is Rendered?

I have made a custom Block that appears on the checkout page of every product item. So each time the product is rendered, that block is called. The block is rendered below every product item. I want ...
Muhammad Muiz Ather's user avatar
2 votes
1 answer
152 views

Unable to override \Magento\Directory\Block\Data class-magento2

Can anybody help me to add a class in getCountryHtmlSelect() I have tried to override \Magento\Directory\Block\Data file using plugin but i can't extend that so i go for perference. added code in di....
Ajith's user avatar
  • 66
0 votes
2 answers
596 views

How to get the product images by their role in Magento2 and display it to on frontend

I am new to magento2, I don't know how to get the product images by their role and display it on the frontend. can anyone help me to understand this flow from scratch, so I can understand how to ...
Naveen Raj Kumar's user avatar
0 votes
1 answer
44 views

Difference Between $block and $this with Example in magento 2.4.4?

I want to know what is the main difference between $block and $this with example. And also wants to know what are the classes of $this and $block.
Niharika's user avatar
1 vote
1 answer
479 views

Adding layout handles to blocks in cms pages

We have a cms page with a content like this: <p>Lorem Ipsum</p> <div>{{block class="Vendor\Module\Block\Feature" block_id="feature_wrapper_block"}}</div> &...
kolaente's user avatar
  • 338
1 vote
2 answers
309 views

how to add cms block in magento without using our own theme and in app/code?

How to Add CMS Block in Magento2 programatically. I want to add a cms block in app/code insstead of app/design using layout or xml files.
Magento Inquiry's user avatar
0 votes
1 answer
50 views

PASS DATA FROM MODEL TO BLOCK

Hello guys i get my data from db with API i want to show data in frontend , i can do this this is function, that return an array of data. public function getComputerAttr($customerId) { $...
Max's user avatar
  • 11
0 votes
1 answer
243 views

Magento2 : Layout block what is the difference between acl="" and aclResource"" attribute

I've been trying to figure out the difference between acl and aclResource both attributes available for <block> directive. I know that aclResource is useful to render the block based on specific ...
Mohamed23gharbi's user avatar
0 votes
1 answer
243 views

Using a block markup tag strips out elements of block created in pagebuilder

When I create a block with pagebuilder that includes background images for the rows, image elements and buttons they all get stripped out when using the {{block id=''}} tag on another page There is ...
Chris Mccabe's user avatar
0 votes
0 answers
67 views

Extension Layout won't work when using a custom theme

I have built an extension intending it to add a block underneath the Add to Cart button on the catalog product page. My extension layout file isn't being executed - instead it just executes my custom ...
Peter Stuart's user avatar
0 votes
1 answer
105 views

Can't add block below add to cart button

I am new to Magento and would like to add a custom block underneath the 'Add to Cart' button. Here is my catalog_product_view.xml file: <?xml version="1.0"?> <page xmlns:xsi="...
Peter Stuart's user avatar
1 vote
0 answers
40 views

block which can be added between products on category page magento 2?

is there any free or paid extension available in which we can add block and this will display on the category page between the products on 20th product, 40th product like this.
Magento Dev's user avatar
  • 1,264
0 votes
1 answer
106 views

How to display cms block in product page if some attribute is set to yes

I want to display cms block if product has the attribute set to yes. A product may have multiple attributes set to yes, and may display multiple cms blocks. Attribute label text will be a BlockId. It ...
scalpel's user avatar
0 votes
1 answer
16 views

How to modify core product block

I have a problem with having any impact on how the site render a block. I want to pass data about shipping price to a product page, and I want it done by creating module, I've made standard: app/code/...
elpiannist's user avatar
2 votes
2 answers
1k views

Magento 2 How to create CMS block with HTML content programmatically

In Magento 2.4.x, How to create CMS block with HTML content (Text, Image with div structure) programmatically in Page builder section?
Saravanan DS's user avatar
  • 1,126
0 votes
1 answer
204 views

Unable to retrieve value from Block

I am using Magento 2.3.5-p2 I am adding a Google Tag Manager integration code at the Catalog Search, thus this requires me to modify the catalogsearch_result_index.xml and add a new .phtml file which ...
Mohd Farhan Bin Ramli's user avatar
0 votes
1 answer
154 views

Magento 2 - How to override footer block

How to How to override footer block Magento\Theme\Block\Html Current block is vendor\magento\module-theme\Block\Html\Footer.php <?php namespace Magento\Theme\Block\Html; use Magento\Customer\Model\...
Ravindrasinh Zala's user avatar
0 votes
1 answer
79 views

Magento 2.3.4 - CMS_Block Query taking up resource

Hope someone can help because I'm aghast. So we have a 2.3.4 store (migrated from 1.9) which we put live recently. After an hour or so, the site completely collapsed under the traffic (apparently it ...
Thomas Harding's user avatar

1
2 3 4 5
37