Stack Exchange Network

Stack Exchange network consists of 175 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.

2
votes
1answer
23 views

My website not showing products on front page

Any help will be highly appreciated. My website https://muzikhausberlin.de is not showing products on the front page, however on other pages products working fine but I can't see any images in a block ...
0
votes
0answers
12 views

How to get the attributes set using the all attributes in phtml page? in magento 2

How to get the attributes set using all attributes in phtml page? In need, the products view page in all attributes in particular attributes set related attributes?
0
votes
0answers
17 views

Migrating block code to Magento v2

We have some custom design blocks in Magento v1 which are utilizing core/zend_template(<block type="core/template_zend" name="CustomPage">) with fetchview. I do not see fetchview in Magento 2 ...
2
votes
1answer
33 views

How to create a default Magento 2 block (catalog/product_list) from a phtml file?

I'm trying to render a default block from a phtml file, without luck. After a lot of research, I learnt that I can use this code inside a page to render the block I want: {{block type=”catalog/...
1
vote
0answers
22 views

How to call block function in model

I'm using TemplateMonter_FeaturedProduct ang I'm building an API to build mobile application. This extension let me add specific products to appear in specific block on the storefront. Those products ...
0
votes
0answers
22 views

function in block not found

I'm trying to trace some code in TemplateMonster_FeaturedProduct extension inside Block. I've found the following line of code: $numberPerView = (int)$this->getNumberPerView(); I searched for ...
0
votes
2answers
28 views

How to use registry in block?

I'm trying to get registry value in my block. Here's how block looks like, <?php namespace Vendor\Dunning\Block\Adminhtml\Dunning\Edit\Tab; class PartPayments extends \Magento\Backend\Block\...
2
votes
2answers
20 views

Attempting To Override Pager - Type Error

Right now, I'm simply attempting to override the Pager class. Without changing anything within it, I've copied it into my module, and then specified the preference in the di: <config xmlns:xsi="...
1
vote
1answer
27 views

Translate text from blocks in admin panel

I am translating text in the blocks with by putting text instead of categories word{{trans "Categories"}}, but I have some text with span element and I don't know how to translate them, If anyone can ...
1
vote
1answer
31 views

Custom Admin Edit form not displayed

I have created a custom module using \Magento\Backend\Block\Widget\Form\Container form with Magento2.3 and I am facing issue while edit form is not showing in Magento Cloud, But local environment is ...
0
votes
0answers
12 views

How to order page links side by side

I have created some pages in Magento 2.2.1 - About Us, News Page etc - and I want to place them beneath the categories on the default home page. I have created pages, blocks, and widgets. However - I ...
0
votes
0answers
17 views

Magento 2: Overriding Sales Order DefaultRenderer (Order Items)

I'm trying to override the DefaultRenderer (commonly found when customer views their order in accounts) so I can do some customisations and include extra data. I've managed to do this successfully, ...
1
vote
1answer
21 views

magento 2 createBlock from argument item

My custom module xml file contains the block code. I want to call that block code directly using createBlock method and set template to show in specific template. My block code is adding animated ...
0
votes
1answer
57 views

Magento 2 get cart items in block class

I have created block for sidebar. I have added below code in my block for compare products. It's working fine <div class="block widget block-compare"> <div class="block-title"> ...
1
vote
1answer
22 views

Block not appearing when giving custom type

I am trying to nest one block inside another block but the child block isn't showing when I set custom block type. If I set both blocks as page/html then both blocks show fine: <?xml version="1.0"...
1
vote
0answers
7 views

Magento 2 add body class into as per current page using toolbar.php plugin for category and search results page

I have created plugin for toolbar.php \Magento\Catalog\Block\Product\ProductList\Toolbar protected function _prepareLayout() { $this->pageConfig->getTitle()->set(__('Category Page')); ...
0
votes
0answers
7 views
1
vote
1answer
16 views

Incorrect behavior when sending email with use a block inside a template

When developing the module I encountered the following problem: inside the my controller (class Index extends \Magento\Framework\App\Action\Action) there is a method that calls a method to send email ...
0
votes
0answers
19 views

I am trying to Create a product Grid in My custom Module Admin Form

I am trying to add a product Grid in My custom Module I searched a internet and found this Solution Magento 2 : How to add product grid in custom module's tab Now there is a function in this ...
2
votes
2answers
37 views

Best way to change block´s template?

I've been studing for the Magento certification and I came across a question in the swiftotter practice exam that said: Can someone explain me why the answer I chose is incorrect? I thought the way ...
1
vote
1answer
33 views

Magento 2 in default newsletter subscribe not working?

I will attached the phtml and php block code but client side mail does not send? subscribe.phtml <div class="block newsletter"> <div class="title"><strong>Newsletter</...
2
votes
0answers
39 views

Magento 2 - Page cache with hole punch

Magento page cache cached some of the blocks that has dynamic value, like Wishlist count on header for logged in customers I can make it dynamic using Ajax, but then it came to my knowledge that it ...
1
vote
2answers
69 views

Nested cache blocks

I have a parent block that has so many child blocks inside it. The parent block has these cache rules: Header: $this->addData([ 'cache_lifetime' => 86400, 'cache_tags' => ['...
2
votes
1answer
14 views

Magento 1.9 - exception 'Mage_Core_Exception' with message 'Invalid block type

Checking the log file of Magento 1.9, in two web site, I find this row: exception 'Mage_Core_Exception' with message 'Invalid block type: ES_Newssubscribers_Block_Newssubscribers How to remove ...
3
votes
1answer
48 views

Is it possible to append a block to the footer in admin dashboard?

I'm trying to append a block to the footer but only on the dashboard page i.e. <footer> [New Template] [Core Content] </footer> How can I achieve this? I've tried a layout file with the ...
2
votes
1answer
57 views

Handling templates without a module name specified

I have a 3rd party extension installed and I needed to overwrite on block because I could not use events or plugins on it. The block is added in the layout file like this: <block class="Vendor\...
0
votes
2answers
35 views

Create Custom block on Product View with form

I'm trying to do a form and put this on Product View. I did some fields and they are saving the results on DB, ok, everything is good. But, I need to insert this block there. Any thing that I help me?...
1
vote
1answer
56 views

How to override protected _prepareLayout function in block in Magento 2?

I wanted to make changes in _prepareLayout() in block. Code is as follow: Block: Magento\Catalog\Block\Category\View protected function _prepareLayout() { parent::_prepareLayout(); $this-&...
1
vote
2answers
36 views

Magento 2 : How to change the currency symbol wise price in list.phtml page?

I will trying but its not working ? <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of Object Manager $currencyModel = $objectManager->create('...
0
votes
2answers
35 views

Magento 2 How to get the configurable products related all child products in list page using object manager?

Magento 2 in how to get the configurable products related all child (simple products QTY) in list page using object manager? Please give me a solution this questions?
0
votes
0answers
29 views

How do I create a “floating” widget/block?

I'm trying to create a floating widget/block that can sit over on the left of my website like the attached picture. I want to advertise my catalogue for download.
1
vote
2answers
51 views

Magento 2: Custom block not working

Route <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd"> <router id="...
1
vote
0answers
42 views

How to show state dropdown in phtml file in magento2

I want to show state drop down in phtml file in magento2 I have a country code <?php $countryBlock = $block->getLayout()- >createBlock('Magento\Directory\Block\Data');?> &...
5
votes
3answers
138 views

Get category id

How can I get ID from this code which is typed into CMS page content? {{block class="Vendor\Module\Block\CategoryList" category_id="49" template="Vendor_Module::subcategorylist.phtml"}} I need to ...
0
votes
1answer
24 views

How to display data using block code?

This is my code: app/code/Vendor/Module/view/frontend/templates/storecategories.phtml <div> <h3> <a href=""> <?php $categoryId = 65; $_objectManager =...
1
vote
2answers
30 views

Getting Error while calling a block `$_product->$_call()`

Fatal error: Uncaught Error: Method name must be a string in D:\xampp-7.1.23\htdocs\indiahicks\app\design\frontend\Mgs\ethan\Magento_Catalog\templates\product\view\form.phtml:19 <?php $...
0
votes
1answer
30 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: ...
1
vote
1answer
25 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
29 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
59 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
65 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
58 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
43 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
355 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
61 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; $...
1
vote
1answer
52 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? Edit: I realized that there was not much information in my question, so it was ...
0
votes
0answers
24 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
71 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
85 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
20 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 ...