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
0answers
19 views

How to pass variable value from phtml JS to block.php?

I have a phtml (system.phtml) with <script> in it and a variable like console.log(data). <?php $checkcustomer = $block->Customerlogin(); ?> <script src="https://d3js.org/d3.v3.min....
2
votes
1answer
8 views

Cannot put an element on the top Footer

Dear Magento developers, Currently I am trying to put an element block on the top of Footer, here is my wanted result: Here is my default.xml <referenceContainer name="page.bottom.container"> ...
3
votes
2answers
89 views

How to add block near a product image in a product detail page in Magento 2

How to add block near a product image in a product detail page in Magento 2
2
votes
0answers
25 views

Magento sampledata sales banners

I have some questions regarding the sales banners on sample data Magento sites. For example the below banner In the blocks editor, the html code for this block looks like this: <a class="block-...
0
votes
1answer
28 views

Magento2 routeId_controller_action make landing page

I make a Block in my custom module and there a logic exist . I have also make controller ,xml file(for define block class and template file) ,template in Controller nothing custom code exist just ...
2
votes
1answer
52 views

Magento 2 - Add meta detail on frontend page using Block

I have custom block in my custom module, which call my frontend custom phtml file. let's say file path: app\code\Vendor\Module\Block\Index\Index.php I need to figure out the way to set meta title, ...
2
votes
2answers
45 views

How to Get Layout Name in which is block is placed

I have My block <block class="Vendor\ModuleName\Block\Frontend\Linked" name="catalog.product.linked" template="Vendor_ModuleName::slide.phtml" /> in this file app\code\Vendor\ModuleName\...
1
vote
1answer
38 views

Get Product Image custom use Helper and Block in Magento 2

How can I put the below code into the module's files like helper/data.php or block/product.php, and how to use it to call Helper and Block into file.phtml . $objectManager = \Magento\Framework\App\...
2
votes
1answer
26 views

Magento 2 - Multiple collection on same block

I have a block where I want 3 different collections with different category filters. I have created collection object in constructor like this: protected $collection; public function __construct( ...
1
vote
1answer
25 views

Get block in phtml file not working - Please help me? [closed]

Get block in phtml file not working - Please help me ! When clicking on the button, it shows popup fancybox but does not show content in it. My phtml <div id="contact-popup"> <?php echo $...
0
votes
0answers
9 views

Block remove from Home page on specific condition

I Make a promotion rule in which set coupon code , Uses per Coupon is 20 and Uses Per Customer 1. override newsletter email template and set coupon in mail. when any user subcribe newsletter then get ...
2
votes
1answer
25 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
18 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
35 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
24 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
28 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
35 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
18 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
23 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
64 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
17 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
33 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
43 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
43 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
74 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
73 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
15 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
59 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
41 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
73 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
46 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
37 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
32 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
43 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
151 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
27 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
33 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
26 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
30 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. ...