New answers tagged

0

Try this code protected $_storeManager; protected $categoryRepository; public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Catalog\Model\CategoryRepository $categoryRepository ) { $this->_storeManager = $storeManager; $this->categoryRepository = $categoryRepository; } public function ...


1

Try: /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $collection */ $collection = $this->collectionFactory->create(); $collection->addFieldToFilter('level', 2); $collection->addIsActiveFilter(); $collection->setStoreId($storeId); $collection->addUrlRewriteToResult(); $collection->addAttributeToSelect('name'); Where $...


1

You can override block by preference in di.xml file in your module : <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Theme\Block\Html\Topmenu" type="...


0

Try using observer for sales_order_place_before event <?php namespace Vendor\Extension\Observer; use Magento\Framework\Event\ObserverInterface; class RestrictOrderObserver implements ObserverInterface { public function execute(\Magento\Framework\Event\Observer $observer) { $order = $observer->getEvent()->getOrder(); // If you want to ...


0

I simply went on the Magento backend in Content -> Widgets -> Add Widget, Type Static Block and in Layout Updates I chose Display on: Specified Page, then CMS Home Page and Before Main Columns, and selected the block. That's it!


0

Sounds like you just have to add <arguments> <argument name="jsLayout" xsi:type="array"> <item name="components" xsi:type="array"> <item name="review-form" xsi:type="array"> <item name="component" xsi:type="string"...


0

If you are looking to switch to that tab, a simple way to do it would be to use jquery's .click() function such that: $(document).ready(function ($) {$("#tabid").click();})


0

For your requirement, you need to do this things. Create one page with empty layout. Set those page width 100%. Now set this newly created page as homepage.


0

Try This app/code/VendoreName/ModuleName/etc di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Theme\Block\Html\Topmenu" type="VendoreName\...


0

Custom file path app/design/frontend/{Package}/{theme}/Magento_Theme/templates/html/test.phtml calling in xml layout file <block class=""Magento\Framework\View\Element\Template"" name=""test_file"" template=""Magento_Theme::html/test.phtml""/> Calling in blocks and cms pages {{block class=&...


0

You can achieve this with a custom SQL statement protected $resourceConnection; public function __construct( ... \Magento\Framework\App\ResourceConnection $resourceConnection, ... ) { $this->resourceConnection = $resourceConnection; } $connection = $this->resourceConnection->getConnection(); $sql = "select id FROM customtable ...


0

Create your custom.phtml here is the path app/design/frontend/{{YOUR THEME NAME HERE}}/default//Magento_Catalog/templates/custom.phtml After add XML <referenceContainer name="content"> <container name="custom.block" htmlTag="div" htmlClass="custom-block" before="product.info.details">...


0

Source of answer https://community.magento.com/t5/Magento-2-x-Programming/Relationship-in-block-and-template/td-p/459182 Case 1: Single Block & Multiple Templates No this can not be true as at a time only 1 template can be assigned to any block. you can not assign multiple templates to any block. the block template is assigned when its instance is ...


1

There is a typo in your template path it should be: {{block class="Magento\Framework\View\Element\Template" template="Magento_Theme::html/breadcrumbs.phtml"}} Note: Use forward slash /


0

Usually, the main template and layout of the contact page can be found in 'vendor/magento/module-contact/view/frontend' If you use a custom theme, check in 'app/design' if you override the contact module


Top 50 recent answers are included