Skip to content

blocks

Auto Added by WPeMatico

How to add groups fieldset with add row in admin block in magento 2

I need to add groups fieldset or bundle fieldset with “Add Row” section. like – $form = $this->_formFactory->create(); $form->setHtmlIdPrefix(‘custom_’); $customerId = $this->_coreRegistry->registry( RegistryConstants::CURRENT_CUSTOMER_ID ); $storeid = $this->_storeManager->getStore()->getId(); $fieldset = $form->addFieldset( ‘base_fieldset’, [‘legend’ => __(‘Details’)] ); $fieldset->addField( ‘percentage’, ‘text’, [ ‘name’… Read More »How to add groups fieldset with add row in admin block in magento 2

How to get related product collection in block

I use this way to get related product collection /** * Prepare and return product collection * * @return MagentoCatalogModelResourceModelProductCollection */ public function createCollection() { /** @var $collection MagentoCatalogModelResourceModelProductCollection */ $myBlock = MagentoFrameworkAppObjectManager::getInstance()->get(‘AntonStudioStockUpdateBlockRelatedProducts’); $currentProduct = $myBlock->getCurrentProduct(); $relatedProducts = $currentProduct->getRelatedProductCollection(); /**… Read More »How to get related product collection in block

How to show address fields in register when you call the block

I have included the register.phtml file in another .phtml file using the following code: <?php echo $this->getLayout()->createBlock(“MagentoCustomerBlockFormRegister”)->setTemplate(“Magento_Customer::form/register.phtml”)->toHtml(); ?> This code is used to display the registration form as a popup. Additionally, I have created an customer_account_create.xml file to enable the… Read More »How to show address fields in register when you call the block

How to remove block arguments in magento 2 using xml layouts

<?xml version=”1.0″?> <page xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:View/Layout/etc/page_configuration.xsd”> <body> <referenceBlock name=”sales.order.items.renderers”> <block class=”MagentoSalesBlockOrderItemRendererDefaultRenderer” as=”default” template=”Vendor_Extension::order/items/renderer/default.phtml” name=”custom_order_view_renderer”/> <action method=”setChild”> <argument name=”alias” xsi:type=”string”>default</argument> <argument name=”block” xsi:type=”string”>custom_order_view_renderer</argument> </action> </referenceBlock> </body> </page>

Arguments shared between multiple instances of same block

I have created a custom block and tried to insert it multiple times in the same page: <block class=”MyCompanyMyModuleBlockProducttabsCategoryProducts” name=”category.products.slider1″ template=”MyCompany_MyModule::producttabs/category-items-new.phtml”> <arguments> <argument name=”category_id” xsi:type=”string”>31</argument> <argument name=”block_title” xsi:type=”string”>Lorem ipsum</argument> <argument name=”block_text” xsi:type=”string”>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</argument> </arguments>… Read More »Arguments shared between multiple instances of same block