Questions tagged [custom-block]

The tag has no usage guidance, but it has a tag wiki.

Filter by
Sorted by
Tagged with
11
votes
1answer
970 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 ...
9
votes
2answers
2k views

$product->getOptions() returns empty result

I am trying to get product details including product custom options value in a custom block i created.This is the code i used on product detail page and it worked there, but when trying to use it on ...
7
votes
3answers
11k views

Custom Block “Invalid Block Type”

I have a custom Block which I'm now trying to break into two sepparate blocks. Here's my folder structure (on app/code/local/MyNamespace/CustomerDashboard): Since I want to break the functions of ...
6
votes
3answers
1k views

How to include module's CSS in CMS pages with module block

I have prepared one module in which I have prepared two .phtml files and included css and js through module layout file. Now, I want to include those .phtml file in different blocks and pages. I have ...
4
votes
1answer
20k views

Add block in header layout

I have added my custom module block in header in layout like below pinsearch.xml <default> <reference name="header"> <block type="core/template" name="pinsearch" as="...
4
votes
2answers
638 views

Magento1 createBlock method returns “bool(false)” in livehost

I've made a module that, in my localhost works fine.. The block shows up and ok, but in "livehost" the block don't appear, so I created a controller to make some tests and see what is the problem. ...
4
votes
2answers
876 views

Mtslideshow SUPE8788 getConfig returns null

I am trying to understand why this code in production is not working (it comes from a custom theme): protected function _prepareLayout() { $uploaderBlock = $this->getLayout()->...
4
votes
1answer
550 views

Access block function in model

In my custom module, I have perform some logical calculations in block to get the value in frontend. And also I need to get that value in model also. So my question is, I call the block function in ...
3
votes
1answer
4k views

magento 2 - How to create a custom “admin” block and display it on an existing Admin page?

I need to create a custom "admin" block and display it on any admin "product edit" page in Magento 2.1.x. But I also want to be able to display it on any admin page, if I need. Which block classes ...
3
votes
2answers
5k views

Magento2 loading admin layout and template in a new page

I can't get my head wrap around this. I have this controller namespace Vendor\Gift\Controller\Adminhtml\Gift; use Magento\Backend\App\Action\Context; class Index extends \Magento\Backend\App\...
3
votes
2answers
681 views

Change $this to different block in related.phtml

I am working in related.phtml in app/design/frontend/[package]/default/template/catalog/product/list/. Here there is a foreach loop: <?php foreach($this->getItems() as $_item): ?> which loops ...
3
votes
2answers
112 views

Magento2: Custom module not working

I have created new module but it is not working.Please Help me on this. registration <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\...
3
votes
1answer
685 views

Magento2 not getting post data from ui component phtml file

I have implemented admin form using UI component. In that, I have 3 separate tabs. Among 3, I have displayed one tab using custom phtml file by using following code in ui component form xml file <...
3
votes
1answer
937 views

How can I insert block before breadcrumbs or just after menu on every page?

I would like to add block to the website (in general on every page) just below menu but not into header, "root" eventually "content". I managed to add it into content but it's not what I wanted. => ...
3
votes
3answers
2k views

How to pass a variable from a.phtml Block to its parent block?

I've created a child block and inside there is a counter. Now I need that value from the counter but the output is/shall before my block. Is that possible? It shall look like this: html output the ...
3
votes
3answers
3k views

Magento 2: Get all category products by category name

anyone knows how to load from my custom block.php all the products of a specific category, I would like to get them by the name of the category and not by the id. I tried to change the standard ...
3
votes
1answer
2k views

Custom Block (Slick Slider) Not Working

Trying to add a Slick(http://kenwheeler.github.io/slick/) slider to homepage. It looks simple enough, but I have been banging my head against the wall for the last 2 days. Here's what I have done: ...
3
votes
0answers
33 views

How to show full product page on home (but show different custom block than product page)

I have a one product store in Magento 2, and want to make it easy to order as soon as possible. So i want to have on the homepage everything that there is on the product page, like order button, ...
3
votes
2answers
73 views

Block fails on (live) server but works on localhost?

I've added a custom block to catalog/product/view.phtml using echo $this->getLayout()->createBlock('colorchart/colorchart')->setTemplate('colorchart/colorchart.phtml')->toHtml(); and it's ...
3
votes
0answers
46 views

Load products page inside phtml page Magento 2

I have a custom .phtml page, and i want to insert products page which contain layered navigation like this: so i already have filtered product collection, is there a chance to do call this products ...
2
votes
2answers
5k views

Calling to custom block from cms page display blank page

I've created a custom block, however when calling the block from cms page displays nothing. Even the content of cms page does not displat that is above the call to custom block Here is How i'm ...
2
votes
4answers
589 views

Move Custom tab at top of left sidebar customer dashboard

I want to move my custom tab from bottom to top in customer dashboard left sidebar. I tried below thing <referenceBlock name="customer-account-navigation-account-link" remove="true"/> &...
2
votes
3answers
124 views

Create block between header and main

I am facing issue with creating a block between header.container and main. so that I can put the banner over there. And I need the banner in home page only please help me for the same.
2
votes
1answer
204 views

Pass multiple variables to view

We can pass a variable to a .phtml view file like this: $currentTime = date("H:i", time()); $someValue = 123; $this->loadLayout(); $this->getLayout() ->getBlock('newsletter_popup') ...
2
votes
1answer
61 views

Block is not shown on custom page

I am a new in Magento. I have installed Magento 2.2. and created 1 module with custom page. There is 1 block on this page, which has to be shown on it. But it is not shown. Please, help me to resolve ...
2
votes
1answer
2k views

Programmatically create and append a block to another block

I've declared a plugin that creates and adds a block programmatically if a condition is true. However, my code outputs nothing, it's like if the created block is not rendered at all. etc/di.xml <...
2
votes
2answers
787 views

Magento 2 Custom New Block without module

I want to display special product on CMS home page in magento 2.1.3 What i did is : 1) created block under app/code/Magento/Catalog/Block/Product/Special.php <?php /** * Copyright © 2016 ...
2
votes
2answers
627 views

Magento 1.8 - Custom Block just on Homepage

I am trying to add a custom block to just the homepage. All pages use the same template which is 1column.phtml In this file I have added a customblock above the content: <?php echo $this->...
2
votes
2answers
3k views

How do you add a custom block in checkout/cart page in magento2?

I am trying to create a custom block on the checkout/cart page so that I can show a countdown to free shipping. I keep getting Invalid block type as an error, though. checkout_cart_index.xml <?...
2
votes
1answer
78 views

How to ovveride a block in custom module?

I want to override the Catalog module. So I created my first custom module, I initiated it in app/etc/modules/MyCompany_Catalog.xml: <?xml version="1.0"?> <config> <modules> ...
2
votes
2answers
2k views

Function call returning fatal error: Call to undefined function getRecentProducts()

Hi I am a newbie to magento. I'm trying to call a custom module block using getChildHtml() function which unfortunately is showing a fatal error: Call to undefined function getRecentProducts() I am ...
2
votes
2answers
673 views

Check if customer logged in not working

I have a block to add link at top based on if customer login like this, when i'm at myaccount page the header link show the right one, but when i go to other page it shows the wrong one, here's my ...
2
votes
1answer
297 views

Add custom stylesheet with my custom block [duplicate]

*In my custom block I want to add custom stylesheet to display the block as like i want. How it can be possible.
2
votes
1answer
694 views

Add phtml to Customer Account Edit in Adminhtml

I tried to add phtml to customer account edit in backend like this: app/code/Namespace/Module/view/adminhtml/layout/customer_index_edit.xml <?xml version="1.0"?> <page xmlns:xsi="http://...
2
votes
0answers
72 views

Magento2 : Problem in block creation

I try to modify the template of a custom option type in backend, sales order view section. In this page, product options are not displayed using a dedicated template, but only by returning Html of ...
2
votes
1answer
246 views

Help create a block to insert view.phtml

Help create a block to insert view.phtml. I have a layout file that outputs to buy in one click in the right column. I need to put this block alongside a buy button. <checkout_cart_index> &...
1
vote
3answers
98 views

How to add a custom block within checkout cart summary in magento 2

How to add a custom block within checkout cart summary in magento 2
1
vote
1answer
1k views

Add custom block in Magento 2 admin dashboard

Is there any way to add a custom block in magento 2 admin dashboard? I have a requirement to add custom table in dashboard. Can anyone help me? My current magento version 2.2.1
1
vote
2answers
695 views

Where is Content block for <reference name=“content” tag

if I use a layout such as: <layout> <{handle}> <reference name="content"> ... {blocks} ... According to docs and tutorial the reference's name attribute points ...
1
vote
2answers
5k views

Get Product Collection based on brand parameter from cms page

I'm creating custom block to get products based on the brand name I'd like to pass the brand name parameter from the cms page like below {{block type="core/template" template="catalog/brand/...
1
vote
2answers
49 views

Magento2: Block not created from controller

How to create block from controller by ajax method? $result = $this->resultJsonFactory->create(); $resultPage = $this->_resultPageFactory->create(); $block = $resultPage->...
1
vote
1answer
2k views

Magento 2: How to add custom form on category page?

I am using Magento 2.1 and I am trying to add one custom form in catalog page. I override the catalog_category_view to my custom module and use this code <referenceContainer name="columns.top"&...
1
vote
1answer
413 views

Custom Block generating an error on template: Magento

I have CMS block in magento admin and it included the following code: <div id="featured-products" class="tab">{{block type="featuredproducts/listing" template="featured/featuredproducts/...
1
vote
1answer
41 views

How I can add custom block to layout using php in Magento 2

I have created a custom block, as I want to add this layout to my current layout. Following is my block: <referenceContainer name="sidebar.main"> <block class="Vendor\ModuleName\...
1
vote
1answer
44 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
2answers
1k views

Magento 2: Custom block doesn't show on the cart page

Namespace/Modulename/Block/donation.php namespace Namespace\Modulename\Block; class Productpoint extends \Magento\Framework\View\Element\Template { public function __construct( \...
1
vote
1answer
6k views

Adding a new custom phtml block to the header

How does one add a new block and template file to the header in Magento2? So far I've created a child theme, which is working, including a default.xml, which is successfully moving other block around....
1
vote
1answer
386 views

Module not working after namespace magento 2

I used this module https://github.com/sohelrana09/magento2-module-additional-shipping-block to add a custom block to the shipment method, when I moved it to another namespace , it does not work ...
1
vote
1answer
682 views

Is this the correct way to add a custom block to before_body_end only on homepage?

Working with Magento CE 1.9.1.0. I have written some custom code which I have placed here: app/design/frontend/mypackage/mytheme/template/page/html/custom_code.phtml I also created a new XML ...
1
vote
1answer
2k views

Magento 2 RC - Invalid block type

I created an extension for Magento on Magento 2 1.0.0 beta. Now I'm trying to get this extension working for Magento 2 RC, but I can't figure it out. What I have is a very simple extension that ...