When we upgrade Magento 2.4.6 then we might get deprecated Zend classes errors in custom modules because of some Zend class removed in Magento 2.4.6. In this blog I added some depreciated Zend classes alternative to fix those error. We have some alternative of Zend class are Laminas classes and Magento classesHere is list of alternative of Zend classes.\Zend_Http_Client::POST => \Laminas\Http\Request::METHOD_POST\Zend_Http_Client::GET => \Laminas\Http\Request::METHOD_GET\Zend_Json => \Laminas\Json\Json\Zend_Filter => \Magento\Framework\Filter\FilterInput\Zend_Http_Client => \Laminas\Http\Request\Zend_Http_Response => \Laminas\Http\Response\Zend_Validate => \Laminas\Validator\Zend_Filter_Input => \Magento\Framework\Filter\FilterInput\Zend_Json_Exception…
We’ll show you how to add category attributes in magento2 and display in category form. We show here 3 easy step for add category attribute and display attribute to category form. Step 1: Create patch file for create category attribute. Create file below.app/code/MageDad/Module/Setup/Patch/Data/AddAttributeCategoryAttribute.php Step 2: In this step we are going to add attribute in category form. Create file – app/code/MageDad/Module/view/adminhtml/ui_component/category_form.xml Step 2: Run setup upgrade commandphp bin/magento setup:upgrade I hope this blog is useful…
When you test your magento code with PHPStan then facing some issue for code qaulity like PHPStan: __construct() has parameter $components with no value type specified initerable type array.Might be your code is like below: And error like below: We don’t know array format of $components and $data so we need to ingore this errors in phpstan-baseline.neonNeed to run below command for fix error: I hope you like this solution.
In this blog in explain about how we can get current admin user details from session.We need to use session class Magento\Backend\Model\Auth\Sessiont to get current loggedin admin data.Here is simple code is to get admin details. Code is writter with PHP8 and supported to magento 2.4.6 😍 Created one simple class and loaded Session in construct method You can get more details about user with different methods like for get admin user name $this->authSession->getUser()->getUsername();Here is…
In this blog, I created admin role save after event to save custom field data in tablecreate events.xml file at app/code/<Vendor>/<Module>/etc/events.xml Now Create observer PermissionsRolePrepareSave for save field field_name data in database. Create file at path app/code/MageDad/Module/Observer/Backend/Admin/PermissionsRolePrepareSave.php I hope this blog is useful for save role field data in database. In case, I missed anything or need to add some more information, Don’t heisted to leave a comment in this blog, I’ll get back with…
In Magento 2, you can use the built-in logging system to add logs for debugging purposes. Here’s a step-by-step guide on how to add log in Magento2: Initialize the Logger in your class To start logging, you need to instantiate the \Psr\Log\LoggerInterface in your class. You can do this by adding it to the constructor. Add Log Statements Now, you can use the $this->logger object to add log statements. There are different log levels available,…