Questions tagged [blocks]

denotes questions about the `Block` classes.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
8 views

Menu scrollbar problem in Magento for desktop (Using Blocks)

i am creating menu from block for my website. While i have to much pages under my About us menu. 1st menu showing 2 columns up and 2 columns down. 2nd while i have many pages so that are not showing ...
0 votes
2 answers
15 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 ? &...
0 votes
1 answer
16 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 ...
0 votes
2 answers
31 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
  • 33
0 votes
2 answers
32 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 :...
1 vote
1 answer
13 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 ...
  • 111
0 votes
1 answer
13 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 ...
2 votes
1 answer
30 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....
  • 31
0 votes
2 answers
32 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 ...
0 votes
1 answer
25 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.
1 vote
1 answer
54 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> &...
  • 288
1 vote
2 answers
38 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.
0 votes
1 answer
23 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) { $...
  • 13
0 votes
0 answers
18 views

How to add dropdown to product variation in grid.phtml

I want add variation dropdown instead of multiple div swatch option. I am not getting how to do in grid.phtml. Below is the code swatch option display <?= $block->getProductPriceHtml($_item, $...
  • 1
0 votes
1 answer
47 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 ...
0 votes
0 answers
35 views

Set the header block to be the first element in the top.links block

I am facing this issue in magento 2.3.4: I want the welcome message to be the first element in the top.links block. Now it is looking like this: For that, I have made some changes inside design/...
0 votes
1 answer
116 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 ...
0 votes
0 answers
65 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 ...
0 votes
1 answer
45 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="...
0 votes
0 answers
8 views

Magento 2.4.2 in admin product edit Advanced pricing in Customer Group Price missing how to create this?

Magento 2.4.2 in admin product edit Advanced pricing in Customer Group Price missing how to create this? Please guide me how to add this fields?
0 votes
0 answers
153 views

How can I pass custom form data and load result page using Ajax?

New to Magento. My goal with this is to have customer pick price range and sort order from a custom form I created, then when form is submitted have Ajax pass the form data AND load the new page with ...
0 votes
0 answers
34 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.
  • 1,214
0 votes
1 answer
42 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 ...
0 votes
0 answers
94 views

How to get widget instance id in its block

I can get widget parameters in the widget class like $this->getWidgetTitle() but here widget_title has been declared in widget parameters in widget.xml file, I want to get the widget instance-id ...
  • 869
0 votes
1 answer
13 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/...
1 vote
2 answers
421 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?
  • 1,094
0 votes
1 answer
48 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 ...
0 votes
1 answer
79 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\...
0 votes
1 answer
40 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 ...
0 votes
1 answer
21 views

Remove block magento

I am facing a problem in the picture. I have two SIGNOUT. How can delete the external SIGNOUT?[![enter code here][1]][1]
0 votes
0 answers
197 views

Magento 2 : Rearrange Block Argument Items Using ReferenceBlock

I'm using magento 2.4 and trying to customize the items ordered table in admin order detail page via MyVendor\MyModule\view\adminhtml\layout\sales_order_view.xml. Here, if I reference the block to add ...
  • 147
0 votes
0 answers
21 views

Render block from outside a block

I'm receiving this kind of string {{block class="Cpy\ModuleName\Block\BlockName" name="mega-menu" template="Magento_Theme::html/mega-menu/mega-menu.phtml"}} Usually, ...
  • 853
0 votes
0 answers
776 views

main.CRITICAL: Error: Call to a member function getId() on null

I'm using Magento 2.4.3 and I'm loading a custom module using someone else's code from the link https://community.magento.com/t5/Magento-2-x-Programming/Magento-2-Product-Reviews-only-by-customer-who-...
  • 1
0 votes
0 answers
172 views

How to extend app/code/Smartwave/Megamenu/Block/Topmenu.php this file Function in Custom Module or in Child Theme?

I need to extend a function from this file app/code/Smartwave/Megamenu/Block/Topmenu.php. By using a module or in child theme. How can i achieve that to extend that file like how to modify that ...
  • 576
0 votes
1 answer
644 views

Magento 2 how to add order view information blocks and sections to my custom tab?

I would like to add Order View -> Information sections to my custom tab at admin end. Here is my layout file sales_order_view <?xml version="1.0"?> <!-- /** * Copyright © ...
1 vote
0 answers
24 views

Can you add Dynamic fields in admin grid?

I am trying to add Dynamic fields in admin gird. i am not using UI to do this. I have added custom field using this $fieldset->addField( 'test_field', 'text', [ ...
  • 45
0 votes
1 answer
334 views

How to set custom action on admin form edit top button in magento 2?

I have one my admin grid in that edit time i add button in top action bar now in that on click i need to set custom action of controller i try this but not working $this->buttonList->add( ...
0 votes
0 answers
114 views

How can I add yotpo review in static block in Magento2?

I want to get yotpo review in my static block and want to show it on the front end. I want to inherit a review like this code. {{block class="Magento\Framework\View\Element\Template" name=&...
  • 33
0 votes
2 answers
557 views

Magento2.4.2 in Elasticsearch 7 reindex not working

We have installing magento2.4.2 with Elasticsearch 7. reindex not running. facing some issues: Catalog Search index process unknown error: {"error":{"root_cause":[{"type"...
0 votes
1 answer
399 views

How to block specific email address?

How to block specific email address? The customer is registered as guest but making series of suspected fraudulent transactions. We see he is using different credit cards, fictitious address and ...
0 votes
2 answers
68 views

How can I get the first level category list?

I'd like to list all first level categories from inside my custom block. I'd like to get the category names and the URLs. How can I achieve this?
  • 115
0 votes
1 answer
129 views

How to override _getHtml() function form topmenu.php file in Magento 2

I want to override _getHtml() function from topmenu.php file using block. So Please help me THANKS.
  • 3,267
0 votes
1 answer
649 views

How to Block Customers by their Address in Magento 2?

I want a feature in which user will be blocked by their Address. Like I will add the address in block list of Magento Admin and then user will not be able to purchase anything if I add their address ...
  • 576
0 votes
1 answer
60 views

How to force reviews to appear on page load? trigger processReviews

I'm trying to make customer reviews appear on the PDP page without clicking on the reviews button. On reviews tab click, ajax request is being sent to the server and I want to send this request on ...
  • 11
0 votes
2 answers
174 views

How to add a full width area in the homepage with 2 columns with right bar?

I'd like to add a full-width area (in order to insert a block) in my Magento homepage which is now set to 2 columns with right bar layout. Should I add a new section before the main content? How? Or ...
  • 115
0 votes
2 answers
141 views

I want to call phtml file from Magento_Theme to static block. but it is giving some error

PHTML file is located in Magento_Theme/templates/html/breadcrumbs.phtml. I tried with the code {{block class="Magento\Framework\View\Element\Template" template="Magento_Theme::html\...
0 votes
1 answer
67 views

Can't find Contact Block

I'm having trouble finding where exactly the Contact-page is located in a shop I got handed down. There is a Block called 'Contact Us info' saved in the Admin Frontend Portion of Content->Blocks, ...
0 votes
3 answers
2k views

Magento 2: How to get last inserted custom table Id without saving new item?

I want to get the last inserted id to my block without adding new data into the table. I want to use this value to automatically filled in my phtml file. I tried getId and it's not working. I just ...
  • 15
0 votes
1 answer
449 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:...
  • 15
0 votes
1 answer
306 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="...

1
2 3 4 5
36