Questions tagged [blocks]

denotes questions about the `Block` classes.

409 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6 votes
0 answers
650 views

Magento : 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 ...
5 votes
1 answer
633 views

How to disable cache for perticular template file in magento 1.9?

We have used full page cache but some particular part of section not reflected. for example, we have a select city in the dropdown but not reflected. check my site- https://vidyutbazar.com/ A ...
  • 3,171
5 votes
1 answer
1k views

Render Javascript on customer_login event

I'm trying to render some javascript when the customer_login event fires by accessing a block on the layout from within the observer. I've successfully registered my observer to execute with the ...
  • 51
4 votes
4 answers
2k views

How to call module block after header?

I have a module layout file below <default> <block name="ampromo_notification" type="ampromo/notification" template="amasty/ampromo/notification.phtml" ...
4 votes
1 answer
2k views

magento2 -custom layout file not loading

i have followed the below link in order to get check if our custom layout xml file is loaded or not using the event: layout_generate_blocks_after In the log file i just get: 2016-06-29T11:07:40+00:...
  • 2,579
4 votes
2 answers
485 views

Magento getting store bestsellers: configurable products, only from current store

Magento getting store bestsellers: configurable products, only from current store We have tested some bestseller codes like from here and here and here. They all work fine if you only sell simple ...
  • 5,332
3 votes
0 answers
31 views

Ordering JS/CSS load order across multiple xml blocks

When rendered, the below core XML loads the require.js file in (for example) Position 10 in the HTML Source: vendor/magento/module-theme/view/frontend/layout/default_head_blocks.xml <head> ...
  • 2,550
3 votes
0 answers
164 views

Magento 2 Is there a way to use product chooser in ui component form (NOT BLOCK)?

Im building module using ui components and need product chooser in my form. But can't find any useful info related to product chooser implementation using ui component. Is it possible to do this ...
3 votes
1 answer
132 views

ReferenceError: {var} is not defined

I have a problem with the frontend_model of the system.xml This is the system.xml <field id="words" translate="label" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="1"> ...
  • 187
3 votes
0 answers
71 views

Cache life time with varnish

Magento Magento\Framework\View\Element\AbstractBlock has method getCacheFiletime, it return lifetime of cache in seconds. How it will work with varnish?
3 votes
1 answer
334 views

Magento2: Phtml file not visible on PDP

I have create a module which consists an extra button on the product description page . For this I have added a layout catalog_product_view.xml which is below. <?xml version="1.0"?> <page ...
  • 71
3 votes
0 answers
29 views

insert different block in the middle of block content

I have a phtml for a block like this : app/code/Vendor/Modul/view/frontend/templates/main.phtml <div class="business-container"> <nav class="mini-head"> </nav> <div class="...
  • 88
3 votes
0 answers
1k views

main.ERROR: Unable to resolve the source file for

if we do any modifications or if we add any image in tm_slider block and click on save button it is taking much time and getting 504 gateway time error and website is also not working 10 t0 15 mins at ...
3 votes
0 answers
80 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....
  • 41
3 votes
1 answer
336 views

Can't access session into admin phtml file on Magento 2

I tried to set a session from a model file and access this on a phtml file like this and it's not working: namespace/vendor/Model/ProcessModel.php: protected $backendSession; public ...
  • 2,632
3 votes
2 answers
915 views

Override minicar sidebar price renderer

How can I override a sidebar.phtml from: module-weee/view/frontend/templates/checkout/cart/item/price/sidebar.phtml I have tried in the following ways: <referenceBlock name="checkout.cart.item....
  • 31
3 votes
0 answers
1k 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-...
  • 1,652
3 votes
1 answer
870 views

Block not showing after layout update

Considering this layout update XML: <?xml version="1.0"?> <layout version="0.0.1"> <checkout_cart_index> <reference name="methods"> <block type="...
  • 143
3 votes
2 answers
3k views

Products on homepage: get more than 12 products

Im trying to show a few products on my homepage I got pretty far using this code: {{block type="catalog/product_list" name="product_list" category_id="74" column_count="5" num_products="24" mode="...
3 votes
2 answers
612 views

How to create a custom block from billing.phtml

I would like to add a new block in the customer registration, edit and billing forms. This block will contain a dropdown control where the customer can select if he wants to register as a company or ...
  • 31
3 votes
2 answers
2k views

Magento Container not working in custom layout

I have created a custom XML layout page that I will be using for my home page. Right now it is a clone of the normal 1column.xml layout, and I'm trying to add a container for an image slider. Here is ...
  • 31
2 votes
1 answer
50 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....
  • 66
2 votes
2 answers
89 views

How to convert layout block to cms block?

I have created a block programmatically which shows category name and image on home page. Following is my code: cms_index_index.xml <?xml version="1.0"?> <page xmlns:xsi="http://www.w3....
  • 427
2 votes
1 answer
79 views

Not able to load Block from Controller function

I have extended the cart.php block and I render the block from my indexAction. In the CartController there are many other actions like addAction, deleteAction etc which calls the indexAction ...
  • 149
2 votes
0 answers
87 views

Take value of a field in a block and place it in another field

I have a problem taking values from a system.xml field to show them in another field. This is the system.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
  • 187
2 votes
0 answers
38 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....
  • 1,391
2 votes
0 answers
31 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-...
  • 21
2 votes
2 answers
255 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="...
2 votes
1 answer
64 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 ...
2 votes
1 answer
240 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 ($...
2 votes
1 answer
1k 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/...
  • 757
2 votes
0 answers
40 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
0 answers
35 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
3 answers
341 views

How can I print a attribute on phtml?

I want show relation information from the products under the descriptions, this information shouldn't be inside a tab but as if it were a dynamic block, for example, each product will have a different ...
  • 337
2 votes
0 answers
393 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,128
2 votes
1 answer
863 views

In which referenceContainer of product page we add block for custom rich snippets of current product?

I have to extend default rich snippets for products. For this I have my script in .phtml file as: <script type="application/ld+json"> { "@context": "http://schema.org/", "@type": "Product", <...
  • 1,561
2 votes
0 answers
329 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 ...
  • 942
2 votes
2 answers
2k views

Rendering Html content for Header Block

I want to get my header part as html and I will use this in some other site with API call. For that I am trying to render using Magento\Theme\Block\Html\Header block and the following code: $this-&...
2 votes
0 answers
67 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 ...
  • 143
2 votes
0 answers
482 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 &...
  • 3,684
2 votes
0 answers
297 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.
2 votes
1 answer
990 views

Call block function from helper

I tried to call the block function from my custom module helper like this: $resultLayout = $this->_resultLayoutFactory->create(); $block = $resultLayout->getLayout()->getBlock('category....
  • 1,484
2 votes
0 answers
806 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?
  • 1,483
2 votes
1 answer
4k views

How to add a CMS Block via XML layout update in Magento 2?

In order to create custom sidebar menus for my CMS pages in Magento 1, I used to be able to create a static block, and then use a widget to place it on all CMS pages that had a 2 column layout with ...
  • 726
2 votes
1 answer
442 views

CRUD logic in Controller or Block?

I have referred several blogs which explains CRUD functionality, some of the blogs write code like saving a model, in a Controller and some in a Block. Blogs CRUD functionality in Block : http://...
2 votes
2 answers
1k views

Magento custom block rendered twice

I create a custom checkout block for checkout success page, but unfortunately the data printed twice, First in the right div inside body, and the other printed after the footer, here is the ...
  • 2,404
2 votes
0 answers
500 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"/&...
  • 325
2 votes
0 answers
112 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
1 answer
722 views

Override block function

I want to filter wishlist product collection with a unique id. I have tried to override a method _createWishlistItemCollection located at the path /vendor/magento/module-wishlist/Block/AbstractBlock....
  • 1,355
2 votes
2 answers
94 views

Add review module to homepage

How do I add the review block that is visible on the category pages, to the home on the right side FROM THE BLOG is located. Do I need to just insert the block type in the cms page? I hoped just ...
  • 69

1
2 3 4 5
9