Hot answers tagged

56 votes
Accepted

How to call static block in left sidebar in a page in Magento 2

If you want to call static block in page Try below code : {{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}} If you want to call in phtml file : Try below code : <?php ...
Manthan Dave's user avatar
  • 9,816
35 votes

Invalid Form Key. Please refresh the page?

This bug arises due to php.ini variable "max_input_vars" Increase it to 10000 through below php function: ini_set('max_input_vars', 10000); OR Using linux command line cd /etc/php/7.0/apache2/ vi ...
Ahmad Vaqas Khan's user avatar
20 votes

how to create custom layout page in custom theme

Your question is very brief, it sounds like you're trying to create a new page layout? If that's correct you need to also declare it in layouts.xml. Official documentation How to Create a Custom ...
Ben Crook's user avatar
  • 15.7k
13 votes
Accepted

Difference Between "page" and "layout" Root Tags in Magento 2

These matters due to a different XSD configurations. The <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/...
Max Pronko's user avatar
  • 1,765
11 votes

Invalid Form Key. Please refresh the page?

This problem is occurred after adding more custom options and categories in the product so because php.ini file not allowed to add more custom options. So, we need to change default settings of php....
Baharuni Asif's user avatar
10 votes
Accepted

Magento 1.9.3.1 404 Product page

This looks to be a new feature of 1.9.3.1 :) The issue is being caused at the bottom of: Mage_Core_Model_Session_Abstract_Varien::_validate() - app\code\core\Mage\Core\Model\Session\Abstract\Varien....
J Duke's user avatar
  • 116
9 votes

Difference Between "page" and "layout" Root Tags in Magento 2

Layout files which open with <layout></layout> are page layouts that declare the wireframe of a page inside the <body> section, for example one-column layout or two-column layout. ...
Alex's user avatar
  • 489
8 votes

How to call static block in left sidebar in a page in Magento 2

This should work: <referenceContainer name="sidebar.additional"> <block class="Magento\Cms\Block\Block" name="yourblockid"> <arguments> <argument name="...
Arunendra's user avatar
  • 7,436
8 votes

Invalid Form Key. Please refresh the page?

If you are running this Magento site on a local machine (local host) as your question seems to indicate, you may have trouble using the: http://localhost/ syntax, as Magento 2 doesn't fully know how ...
Jeff Finkelstein's user avatar
6 votes

How to get list of pages in Magento 2

For your information, even though the answers posted look like valid answer, it is recommended to use service contracts in Magento 2. In your case a valid code would be to first inject the right ...
Raphael at Digital Pianism's user avatar
6 votes
Accepted

Magento 2: "404 Not Found" when calling a controller

You need some little modification. Jurgis/Twilio/registration.php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, '...
Sohel Rana's user avatar
  • 35.7k
6 votes

How can i get product thumbnail image, sku, name, details, if enter sku on custom page

I am assuming that the customer is entering the sku of product and that sku you are getting in post value. so for getting more details of product from the sku you can use the following code : $sku = ...
Vikalp Saxena's user avatar
5 votes

Best way to check if page is home page

If you are looking for the CMS Home Page, Method 2 is better: easier to understand more explicit faster, but I only mention it because you asked, the difference is insignificant But if you want to ...
Fabian Schmengler's user avatar
5 votes

How to get the current page Identifier ( URL key ) in Magento 2?

Copy this code in any phtml file to get current cms page id and identifier in magento2: <?php $objectManagerCms = \Magento\Framework\App\ObjectManager::getInstance(); $cmsPage = $objectManagerCms-...
Prince Patel's user avatar
  • 22.7k
5 votes
Accepted

Where is stored the content of a CMS page? How to create a whole new page?

The content of your CMS page is stored in the cms_page table If you want to create page in Magento you can create from cms->page or you can write new controller and create a layout handler in local....
Vaibhav Ahalpara's user avatar
5 votes
Accepted

Magento 2: Add child div containing all items in columns

Create a file named 2columns-left.xml in your theme under below path: app/design/frontend/Vendor/theme/Magento_Theme/page_layout/2columns-left.xml and use the below content for 2columns-left.xml: ...
Sukumar Gorai's user avatar
4 votes
Accepted

How to show simple calatog search form on CMS page?

There is no widget available for this, but pasting the following code into a CMS page or Static Block will allow you to put a search block where you want to have it: <form id="search_mini_form_cms"...
Vladimir Kerkhoff's user avatar
4 votes

How to get the current page Identifier ( URL key ) in Magento 2?

you can get the page id like this: $pageId = $this->_request->getParam('page_id', $this->_request->getParam('id', false)); if you are not in a controller, you need to inject an instance ...
Marius's user avatar
  • 198k
4 votes

How to move product title after products image in Magento 2

Add this before body tag end <move element="page.main.title" destination="content" after="product.info.media"/> Please see following code <page layout="1column" xmlns:xsi="http://www.w3....
Mukesh Prajapati's user avatar
4 votes
Accepted

Magento 2 - How to hide/remove custom attribute from backend product edit page?

This is very simple, follow steps below : Go to the file /vendor/magento/module-catalog/Ui/DataProvider/Product/Form/ProductDataProvider.php Then you can remove/hide product attribute by function ...
Magetop E-commerce's user avatar
4 votes
Accepted

404 page not found error. Custom Page

Please correct your file path with below structure app/code/SimpleMagento/Custom/registration.php Content for this file is.. <?php \Magento\Framework\Component\ComponentRegistrar::register( ...
Kishan Savaliya's user avatar
3 votes

Magento 2.0 Call cms page in phtml file

Your phtml is rendered by a block class. You need to add this in your block class. protected $pageFactory; protected $brandPage; public function __construct( .... \Magento\Cms\Model\...
Marius's user avatar
  • 198k
3 votes

How to get list of pages in Magento 2

you can get it from object Manager $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $collection = $objectManager->get('\Magento\Cms\Model\ResourceModel\Page\...
Amit Samsukha's user avatar
3 votes

Best way to check if page is home page

On a side note, it's good to notice that the Magento\Theme\Block\Html\Header\Logo class provides a isHomePage method that looks like this: public function isHomePage() { $currentUrl = $this->...
Raphael at Digital Pianism's user avatar
3 votes
Accepted

Magento 2 Add some content before body closing tag on every page

You can use before.body.end as the reference name and add the block using layout/default xml Here is an example: Magento 2 add script before closing body tag Look at KAndy's answer.
Aedonis's user avatar
  • 435
3 votes

How to customize product page in Magento 2

to customise product view page in magento2 you need to create a theme, you can find all information for new theme creation here after theme creation, you can manage product page by following path ...
Emizen Tech's user avatar
3 votes
Accepted

Speed up magento by htacess

You need to add compression code into you .htaccess file just like mine as below: ############################################ ## uncomment these lines for CGI mode ## make sure to specify the ...
Vicky Dev's user avatar
  • 1,992
3 votes

Magento 2: How to reset Per Page Record Show in Admin

I have one dirty solution, before do this take a backup of ui_bookmark table. Page limits are stored in ui_bookmark table, in that table change value 1000 to whatever you want In ui_bookmark table ...
Bilal Usean's user avatar
  • 9,947
3 votes
Accepted

Translate Pages by store view

We can achieve this by creating the different CMS pages which assign to the different Store Views. For example: we have three store views, we can create three different CMS pages with the same url ...
Khoa TruongDinh's user avatar
3 votes

Check if currenty page is checkout cart

You can use this : $handle = $this->getLayout()->getUpdate()->getHandles(); if(in_array('checkout_cart_index',$handle)){ // cart page }
Ashish Jagnani's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible