Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [blocks]

denotes questions about the `Block` classes.

0
votes
0answers
9 views

Magento 2: How to add block inside block html content through XML file

I have created my custom arithmetic captcha. I want add that captcha to my custom form through xml file without defining in phtml file on custom layout. For example: Testimonail submit form: ...
0
votes
2answers
20 views

Which block file calls for My Account page when it loads

I have written some helper functions, which does some database inserts The problem is I am calling all these functions from my phtml which gets loaded first time when My account is loaded for the ...
0
votes
1answer
22 views

Module's custom grid is not loading from container

My container is loading, but I'm getting this error message: Call to a member function setSaveParametersInSession() on boolean Which from my searching shows that the grid file is not being loaded. ...
0
votes
1answer
35 views

How do I show child product quantity inside a config/grouped product

I'd like to display the childProduct saleable stock quantity within a grouped or configurable product page on magento 2, I can put in various blocks that supposedly call the stockQty but it's always ...
0
votes
1answer
29 views

Magento2 render custom block in adminhtml layout.xml

I can not render my custom block within my custom template, Point is on newsletter subscriber, I extend newsletter_subscriber_form.xml, Add container within my block but it says that template is ...
0
votes
2answers
25 views

Modify product collection in M2

I am overriding Magento\Catalog\Block\Product\ListProduct In function _getProductCollection I have added some extra code. public function _getProductCollection() { $collection = parent::...
0
votes
3answers
35 views

Magento 1 Redirect only works once, works again after refreshing cache

I want to add a simple redirect if a customer is not logged in when trying to access one of my categories. Now, I have created a test.phtml file and added it in my theme page/test.phtml with ...
4
votes
2answers
179 views

When it is good to use viewModel ? What is difference between viewModel and Block?

I am bit confuse about using viewModel in Magento. I am not getting exact difference between viewModel and Block. In which case using viewModel is best case? Any help will be appreciated.
1
vote
1answer
50 views

Magento 2 Templates: How `$block` is assign in template?

Can you please tell me where the assignment of the $block variable to the template occurs? \Magento\Framework\View\TemplateEngine\Php::render() I found : $tmpBlock = $this->_currentBlock; $...
0
votes
1answer
26 views

How add a country selector in the header section?

I need add a country selector in the header section, next to the currency selector. How is the right way to do this?
0
votes
0answers
23 views

Install layouts and templates from the theme divante

I installed the theme https://github.com/DivanteLtd/magento2-rapid-theme, the theme got up, everything is in order, I don’t understand how to set the main page to make it as an example. The topic has ...
1
vote
2answers
66 views

Magento 2 add custom static block on product detailed page next o addtocart button

I am working with the Magento2, in that, I like to add a custom block on product detailed page, next to add to cart button. for that, i wrote the below code on catalog_product_view.xml <body&...
0
votes
3answers
33 views

how to pass a variable from one phtml to another?

I have two phtml which have its own unique block file. I need to pass variable from one phtml to another. PHTML 1 <?php $option_id = 20; ?> <a href="<?php echo $baseUrl ?>/...
0
votes
0answers
14 views

what are all possibility available in magento 2 for all block and template relations?

Recently, I received this question from a reader of my personal blog and it's puzzled me too. He also asked another question: block can be assigned to multiple templates? I think a template can be ...
0
votes
1answer
12 views

Own recently viewed widget (magento 2)

I want to make own recently viewed widget, cause this standard loads items with javascirpt (I want to have items directly). So I made this code, based on other posts: namespace AA\WidgetRecently\...
0
votes
2answers
28 views

Magento 2 add new argument in the reference block and get into the phtml

I am working on reference block concept, in that I need to add new arguments and get the argument value on the .phmlt file. in catalog_product_view.xml I've added the below line of code. <...
1
vote
2answers
48 views

How to get customer gender as text from its integer value in magento 2

I want to get customer gender value like Male or Female in magento2? How to get it in \Magento\Customer\Block\Account\Dashboard\Info block, I am doing something like this $block->getCustomer()-&...
0
votes
1answer
16 views

Magento 1.9 overwrite core

Is it possible to overwrite Magento core functionality in this way? - Mage_Sales_Block_Order_Total { protected function _initTotals(){ //this is core } } and overwrite it with this - ...
1
vote
1answer
52 views

Magento 2 Override Gallery.php file

I would like to override /vendor/magento/module-catalog/Block/Product/View/Gallery.php file getGalleryImagesJson function In result I would like to get - public function getGalleryImagesJson() { ...
1
vote
1answer
35 views

How to add Advanced Search form in Pages on homepage in Magento 2?

I am trying to add advanced search form as a block in Pages, but the following code is not working? {{block class="Magento\Framework\View\Element\Template" template="Magento_CatalogSearch::...
0
votes
0answers
44 views

Magento 2.3 Fatal error: Uncaught Error: Call to undefined function mime_content_type()

Fatal error: Uncaught Error: Call to undefined function mime_content_type() in when trying to upload image from admin blocks. Please check screenshot
0
votes
1answer
20 views

How to create custom admin grid using block without using ui component in magento2.2.5?

How to create custom admin grid using block without using ui component in magento2.2.5? Any help would be appreciated.
0
votes
1answer
25 views

How to get related product collection in block

I use this way to get related product collection /** * Prepare and return product collection * * @return \Magento\Catalog\Model\ResourceModel\Product\Collection */ public function ...
0
votes
1answer
16 views

Is it a simple way to set conditions for widget of type CMS static block?

I want a CMS static block to appear in some product pages, but not all. The condition would be "brand is xxx", but unlike other widget types there is no condition option on Widget Settings. Is there ...
0
votes
0answers
10 views

How to always keep my block in the same section regardless of the template to be used?

Develop a block which I have positioned in a specific section of the product detail page, this works perfectly but if I change the theme of my store the block is no longer positioned where I need <...
0
votes
2answers
23 views

Multiple use of `getConnection()` in a single block and impact performance issues

I found a module someone created and looked into the code. I found that this person was making a lot connection as such in a single block: public function checkStoreExists($storeID){ $connection =...
0
votes
0answers
28 views

How to fetch product data into custom .phtml block on product view

I'm having trouble trying to fetch Product data such as price, SKU etc into a custom .phtml file referenced as a block within my catalog_product_view.xml file. Here's what I'm struggling with... I'm ...
1
vote
3answers
79 views

Cart details not getting in mini cart

For some purpose (something like popup) I'm trying to fetch cart details in minicart.phtml from Magento2\vendor\magento\module-checkout\view\frontend\templates\cart\minicart.phtml. I directly ...
0
votes
0answers
10 views

CSS & navbar edits for a Magento noob - ver. 2.2.6

I need to make a few simple changes to an existing Magento site, and although I have some wordpress experience, my Magento is currently 0. It's using a theme called Smartwave Porto, and the changes ...
0
votes
1answer
30 views

Add a static block(widget) before the breadcrumbs

I'm using Magento 2.3.0, and I'm trying to add a block before the breadcrumbs, without any padding or margin. I've created a block from the back-end, then my widget using this block, and then placed ...
0
votes
3answers
63 views

Custom registry is not retrieved in block magento2

I am setting custom registry in my module like below. here is my controller file code. use Magento\Catalog\Api\CategoryRepositoryInterface; use Magento\Catalog\Model\Category; use Magento\Framework\...
1
vote
4answers
125 views

What is the functional difference of Block & Container in Magento 2?

Block vs Container functional difference. I have followed this url but doesn't clear much for me. Which type of classes are extended by block and container. Note : I know how containers and Block ...
0
votes
1answer
47 views

Element 'block', attribute 'remove': The attribute 'remove' is not allowed. Line: 745

I'm getting this error when I hit the front end. Couldn't able to find any solution regarding this. 1 exception(s): Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'block'...
1
vote
3answers
37 views

Can I and should I call Block methods from its' View Model?

I have a template and should write some logic. I have made a view model and I'm calling it from a template. Should I call block methods from the view model? And if so, how can I do it?
0
votes
0answers
35 views

Edit up-sell block to show more than 1 product

When I add, products on the up-sell tab in the backend. It show each product in a single block. instead of a nice layout of 2 or 3 products in each line. How can I edit the block layout for the up-...
2
votes
1answer
50 views

What is the use of getFormActionUrl()?

In Magento2.1.10 I am trying to make admin grid module and found below function in given path \app\code\xyz\Grid\Block\Adminhtml\Grid\addrow.php public function getFormActionUrl(){ if ($...
0
votes
1answer
43 views

Pass boolean or variable from Child Block to Parent Block?

I'm probably thinking about this the wrong way, but I have two blocks and one is the child of the other. In the parent's template file, I'm calling getChildHtml() and rendering the child block that ...
1
vote
1answer
36 views

call block from controller via ajax

I call controller function from phtml via ajax, it calls controller function Now i am trying to call block function in controller it is not working Controller code public function __construct( ...
0
votes
2answers
61 views

Registry not working in magento 2

I need to call the controller function from block . in magento 2 i use the registry. In my block i wrote public function __construct( Template\Context $context, \Magento\Catalog\...
1
vote
1answer
19 views

not able to render phtml file magento 1.7

this is my config file <?xml version="1.0"?> <config> <modules> <Ilogix_Regionbased> <version>0.1.0</version> </...
0
votes
3answers
80 views

How to hide a div in .phtml if a customer is logged in magento 2

I want to have a block in home page that show text and button if customer is not logged in and if he is logged in this block have to disapear so how to proceed any help please here is my code in ....
0
votes
0answers
9 views

Put price.phtml into a specific block to exclude it from Lesti FPC?

I am not showing prices to guest users, only to those that are logged in. I am also using Lesti FPC. The problem here is, that Lesti caches the shown prices and shows them to not logged in users or it ...
0
votes
2answers
31 views

core/template block not showing

I am trying to add a block on my checkout page but for some reason its not working. <block type="core/template" name="checkout.cart.consultant" as="consultant" template="checkout/cart/consultant....
0
votes
0answers
26 views

magento 2 in update password to hash in save to database not working?

I will try to change password but its not working! <form method="POST"> <label>Old Password : <input name="old_password" id="old_password" type="password" /> </label> <...
0
votes
1answer
64 views

Magento 2 - Move Block Not Working

I've created a faqs.xml for a bespoke page template and this is my code: <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/...
0
votes
0answers
14 views

Magento 2 in how to change the password in direct in database link to connect using Seller without hash method?

i have try to change direct connect in database but its not working? <input type="password" placeholder="New Password" id="password" required> <input type="password"...
0
votes
0answers
22 views

Magento 2 in How to change password in programmatically without hash method in password? [duplicate]

I am trying below code but it is not working $customer = $this->_CustomerRepositoryInterface->getById($id); $customerSecure = $this->_customerRegistry->retrieveSecureData($customer->...
0
votes
1answer
31 views

M2 | How to find referenceBlock name for the Sales Order View : Account Information Section?

Part1: I need to know the referenceBlock name for: Part 2: and put a button at: “If you have knowledge, let others light their candles in it.” ― Margaret Fuller
0
votes
0answers
16 views

Magento 2 | Get billing country in sales email as block

We run an online shop in Germany and ship to non-EU countries like Switzerland and Norway. Those orders or better invoices get calculated without any tax/vat. The only downside of that is that we must ...
0
votes
0answers
11 views

Magento 1 product options inside popup or cms page

I am trying to display product options in cms page or popup. I am trying to find out if there any way to display it in a similar way like this: {{block type="catalog/product_view" product_id="391" ...