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.

9
votes
0answers
764 views

Magento2: Conditionally replace block template and class the right way

This rather trivial requirement turns out be quite a pain for us in recent days, as we couldn't find a satisfying existing solution, yet. The Task We are trying to replace certain blocks with a ...
5
votes
0answers
599 views

Template block has not been whitelisted error

I have a site with a CMS page using the 'core/template' block, and getting an error Security problem: core/template has not been whitelisted - even though the 'core/template' is clearly listed in the ...
3
votes
0answers
69 views

Block data are not shown in PHML magento 2

I am new to Magento 2 module development. I have a custom table sample_data(id,sample_text,sample_number) I want to fetch a listing of this custom table.But unfortunately when I type www....
3
votes
0answers
649 views

magento 2: \Magento\Theme\Block\Html\Topmenu $this->_menu

I am currently working on a custom block class that extends \Magento\Theme\Block\Html\Topmenu I have the following in my template file that uses my custom block class: <?php $menuTree1 = $block-...
3
votes
0answers
64 views

Magento 2.1 : Cannot retrieve session variable

Im trying to save form token in session variable and get it back in the result page when the form is submitted. I created the following Session Model to handle sessions in my custom module: <?php ...
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
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-...
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 ...
2
votes
0answers
31 views

Custom plugin files updated code is not showing in admin panel though cache is cleared

I have created a custom module. Controller files are working fine. I am trying to update my module MySQL version and adding new fields to the module in block folder files but they are not applying in ...
2
votes
0answers
26 views

Magento 2: How to remove Theme block in admin?

How to remove this block in back-end Categories > Design > Theme block New product > Schedule Design Update > New Theme block thank you!
2
votes
0answers
102 views

Magento 2: How to validate cart price rule in product view?

I'm trying to show the price rules in the product view, but I can not find a way to validate if a product meets the rule... At the moment I just get all the rules. Block: class RuleDescription ...
2
votes
0answers
53 views

Magento 2 :Header section modifications

I'm trying to understand how the entire header section is put together, and wanted to move some things around just to try to understand how Magento is putting everything together. How could I ...
2
votes
0answers
428 views

Magento 2: How to add Estimate Shipping and Tax in Minicart?

I want to add Estimate Shipping and Tax block on Minicart. It is possible to calculate tax and shipping from minicart block?
2
votes
0answers
415 views

Removing welcome message and breadcrumbs stops the title tag appearing on category page

I have the following lines of code in my Magento 2 template's Magento_Theme default.xml file: <referenceBlock name="header" remove="true"/> <referenceBlock name="breadcrumbs" remove="true"/&...
2
votes
0answers
22 views

what is the equivalent class of Mage_Core_Block_Text_Tag_Js in magento2

what is the equivalent class of Mage_Core_Block_Text_Tag_Js in magento2? class Mage_Core_Block_Text_Tag_Js extends Mage_Core_Block_Text_Tag { protected function _construct() { parent:...
2
votes
0answers
569 views

Magento 2 - Get Category Name in block

I'm trying to get the category name in a block for the home page so that when the visitor changes the language, the name of the category will translate depending on the selected language, like with ...
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 ...
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')); ...
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');?> &...
1
vote
0answers
121 views

override getLoadedProductCollection of \Magento\Catalog\Block\Product\ListProduct

I am overriding getLoadedProductCollection() in my block where performing some custom query public function getLoadedProductCollection() { $myCategory = $this->...
1
vote
0answers
86 views

How to create search select box using block class

I want to create a select box like the below I know this can be done using Ui components, but i want it to be done using form.php class (block class) Currently i am just using the simple select box ...
1
vote
0answers
427 views

Error filtering template: Invalid block type

I'm trying to create my own widget in Magento 2 however I get this error: Error filtering template: Invalid block type: Inchoo1\CatalogWidget\Block\Product\ProductsList My code is identical to ...
1
vote
0answers
68 views

Magento 1 get all checkout child's block on ajax request

I create an action that will return to checkout page when I called it. My code is, echo $this->getLayout()->createBlock('opc/wrapper')->setTemplate('opc/wrapper.phtml')->toHtml(); But it ...
1
vote
0answers
939 views

Magento2: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

The above code written in catalog_product_view.xml in module-catalog. For this block, customer info in header after login not loading. In console I'm getting this error: SyntaxError: JSON.parse: ...
1
vote
0answers
274 views

Magento 2 : How to remove block from controller?

I've been trying to remove block from controller. I can able to render from controller but i need to remove existing layout block when new one render. Vendor\Module\Controller\Grouprequest.php &...
1
vote
0answers
311 views

Magento 2 set block template in layout vs in block

There are two ways to set a blocks template. Either in the block using $this->setTemplate('Vendor_Module::template.phtml'); or in layout <block class="Vendor\Module\Block\BlockName" name="...
1
vote
0answers
68 views

calling {{block type=“core/template” template=“custom/custom.phtml”}} stop working after 1.9.3.7

I called a .phtml block inside a CMS Block with command {{block type="core/template" template="custom/home-slider.phtml"}} and it has been working fine on Magento version 1.9.3.2. I upgraded core ...
1
vote
0answers
90 views

Magento 2 How can i Change Sortorder in fornted order_view.xml in order_total

I want to change sorting order in order_total block in frontend order view page. can any one tell me how i can change sorting order.
1
vote
0answers
79 views

How to display multiple instances of products list, each by category id

I have this code and it displays the product name and product url by category id. Question 1 = How do I add the product image to the echo? Question 2 = How can I change the code so I can use multiple ...
1
vote
0answers
417 views

included translation inside block in email template

I'm wondering does it's possible to use translation inside the block that include in email template. It's my piece of code email template: {{block class='Magento\Framework\View\Element\Template' area=...
1
vote
0answers
52 views

When enable Block HTML output from Cache CMS Widget show previous data

When I Disable Blocks HTML output my Widget working good but when i enable Blocks HTML output it shows wrong or previous output. Actually my theme shows category from widget and i facing this ...
1
vote
0answers
28 views

Magento 2 : Is there a file system map for Magento 2?

Ultimately I want to add code snippets to some or all pages on my website, specifically, the code is the Facebook pixel code is the google tag manager code. I've found a number of similar questions ...
1
vote
0answers
24 views

Overridden (extended) Block function still called

I have made an extension for magento 2 (that filters the products shown depending on user). I have extended the file module-catalog/Block/Product/ListProduct.php for this and overwrittien the ...
1
vote
0answers
419 views

how to replace block in output in magento2?

I need to render products list page with custom ids which should be passed like http://mymagentostore.com/?ids=1,2,3,4,5 (or any other controller action instead of cms_index_index) For this purpose, ...
1
vote
0answers
683 views

How to add custom category block

I'd like to create a new custom category block, that will display it's subcategories. I have created a new file: vendor/magento/module-catalog/view/frontend/templates/category/subcategories.phtml ...
1
vote
0answers
43 views

Moving a referenced block via arguments?

Is it possible to reorder elements by passing an <argument> inside a referenceBlock tag if I am not able to add my after/before where the block was first called?
1
vote
0answers
17 views

Setting up proxy for constructor arguments vs. etc areas

Generally it is prefereable to set .xml configuration files only for areas that will use it. I want to set some proxy object for my classes__construct()` arguments. In case of models it can be not so ...
1
vote
0answers
481 views

Error: Mage_Core_Exception: Invalid block type: Mage_MyModule_Block_Classname

I'm getting an exception in my log which says: Mage_Core_Exception: Invalid block type: Mage_MyModuleName_Block_Classname in C:\xampp\htdocs\magento\app\Mage.php:595 Stack trace: #0 C:\xampp\htdocs\...
1
vote
0answers
212 views

M2 - How to add a block in category page before products prices block

I'm trying to add a block (with template) in category page before products prices block (<?php /* @escapeNotVerified */ echo $block->getProductPrice($_product) ?> in list.phtml). I've ...
1
vote
0answers
592 views

Magento 2: Adding a new Block to Checkout_Cart_Item_Renderer

I am trying to add a custom button next to the gift_options, edit, and remove buttons inside the Magento 2 checkout/cart page Inside my custom theme I have created the Magento_Checkout dir. Inside ...
1
vote
0answers
147 views

Magento custom cache issue on product view page

We added the custom cache for product view page. We rewrite the view.php file and write below code : <?php /** * Rewriting Product View block */ class XXX_YYY_Block_Catalog_Product_View extends ...
1
vote
0answers
2k views

Magento 2 Block/Template not showing

I have a module I've written, and am trying to display a block. All that is showing up is a blank page. If I put an echo "blah"; exit() in my controller, it does output that just fine. No errors in ...
1
vote
0answers
51 views

How to csll Catalog/Layer_View block in controller to get loaded attributes

I want to use below code in controller but not working. $block = $this->getLayout()->getBlock('catalog.leftnav'); I used in phtml file here, it is working fine. but it is not working in ...
1
vote
0answers
235 views

Magento 2 - CMS Pages, Blocks and Layouts

I am fairly new to Magento, I read trough the documentation and everything I could find explaining the frontend developement process. But I still do not get some of the basics. Here is a simple ...
1
vote
0answers
87 views

On editing the newsletter from the customer dashboard, it goes to a blank page

When i click on the edit link in the newsletter section of my account page. it goes to a blank page, also when i check the ManageController in the newsletter section, if ($block = $this->...
1
vote
0answers
410 views

prepend field to onepage checkout billing form

The onepage layout's file billing.phtml offers the following entry point: <?php echo $this->getChildHtml('checkout.onepage.billing.extra')?> So I can hook into that and do: <...
1
vote
0answers
76 views

Magento2 2.0.7 enterprise - Menu Override is just showing a blank page after adding a simple override

I'm just doing a simple override to modify the structure of the menu. But weird thing is after creating the module and just extending the topMenu. It just gives a blank page. Here is my current code :...
1
vote
0answers
428 views

Magento-2 Block rewrite not working

di.xml code of my module <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config....
1
vote
0answers
179 views

Magento bestseller block method - where addCategoryFilter not working

we are creating a bestseller block and use the code below. We are facing two problems. One of which is that when I add a category filter then the method $collection->addCategoryFilter($category) ...
1
vote
0answers
31 views

Manipulate Head based on CMS block

I have a block which I can call by using the following in a CMS page's content: {{block type="karl_catalog/supplier_product" supplier_id="1242" template="karl_catalog/supplier_product.phtml"}} This ...