Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Hot answers tagged

10

echo Company_Module_Model_Somemodel::SOME_CONST; This one is way to go because Magento uses an autoloader and your class will be autoloaded by name For further detail please check the reference link https://stackoverflow.com/questions/16792370/proper-way-to-handle-model-constants-in-magento I hope this will help


7

Short answer: Because Magento does not use the class you think it uses. Long answer: It is because of plugins/interceptors. So, for every class that has methods that has plugins, magento generates a class with the same name as the original class and adds \Interceptor at the end. You can see that in your error message. This interceptors extend the original ...


6

SKU should be empty or string. In your case, it is null or not a string. Run follwoing query will resolve your issue if it is null sku related error: UPDATE catalog_product_entity SET sku='' WHERE sku IS NULL; You can check your corrupted sku and fix that.


6

Need to recreate Interceptor Run di:compile command php bin/magento setup:di:compile


5

In Magento 2.3 configs present only on the backend vendor/magento/module-cms/etc/adminhtml/di.xml Copy that file to your module front app/code/{Provider}/{Module}/etc/frontend/di.xml


5

Here you can find the way how to avoid usage of Registry - https://www.atwix.com/development/alternatives-for-deprecated-registry-class-magento-2-3/


4

Didn't test this, but I think $result = $this->imageUploader->upload('slide'); should be $result = $this->imageUploader->upload('image'); //use the name of the field not of the fieldset. Also add this inside the <item name="config" xsi:type="array"> element <item name="dataScope" xsi:type="string">image</item>


4

In Magento 2.1.* target _blank is not working Following file is responsible to render action in admin UI component Grid vendor/magento/module-ui/view/base/web/templates/grid/cells/actions.html Change: attr="href: $action().href" to attr="target: $col.getTarget($action()), href: $action().href" For action dropdown change: attr="href: $action()....


4

I want to clarify the difference, as the 2 files are not redundant and you may still need to modify both files in most cases. Especially since some times, we use the command line to run some Magento commands. As the other answers mention, running phpinfo() will let you know which php.ini file you would be using. However, the two files exist for two separate ...


4

You can use the Magento framework methods instead of core php functions(AFAIK for the security reasons Magento discouraged these types of functions) For example, use Magento\Framework\Filesystem\Io\File; /** @var File */ private $file; /** * @param File $file */ public function __construct(File $...


4

Strings can contain typos. You can not use the "jump to class" feature on strings from your IDE. Refactoring in an IDE will find ::class notations and not strings.


4

Why not? $cms = $this->collectionFactory->create()->toOptionArray(); $options = [ // your code [ 'label' => __('CMS pages'), 'value' => $cms ] ];


3

Note that there is no CategoryRepository, but there is a CategoryListInterface that you can use in conjunction with a SearchCriteriaInterface Something like this should work: /** @var \Magento\Catalog\Api\CategoryListInterface */ protected $categoryList; /** @var \Magento\Framework\Api\SearchCriteriaBuilder */ protected $searchCriteriaBuilder; /** * ...


3

Seems like you are running on PHP 7.x where method signature compatibility is strictly enforced. The only current version of Magento 1.x that supports PHP 7.x is 1.9.4.0 or patched previous versions. If you're running a previous version and don't want to upgrade to 1.9.4.0 for some reason then the Magento 1 PHP 7.2 patches are available here


3

In Block :- protected $taxHelper; public function __construct(\Magento\Catalog\Helper\Data $taxHelper, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency ){ $this->taxHelper = $taxHelper; $this->priceCurrency = $priceCurrency; } public function finalPrice($product) { return $this->taxHelper->getTaxPrice($product, $...


3

you have 8 levels of foreach-if-try structures in your code. Starting from if (isset($data['itemId'])) { you have if-try-foreach-if-if-foreach-if-if. You should keep this number below 5. In your case you can simply do that by creating a new method in the class. Let's call it processItem with this code. private function processItem($item) { $options ...


3

There are 3 possibilities: 1. You don't have PHP installed. In that case run: sudo apt-get install php php-mysql 2. You have PHP installed but not enabled. You can try running: sudo a2enmod php7 sudo service apache2 restart 3. You have PHP installed and enabled but you haven't restarted apache. sudo service apache2 restart


3

This seems the duplicate question, Please refer here. How to make auto select first child product of configurable product in magento2?


3

Try Foreach loop will help. Syntex : $data = $cms->toArray(); foreach ($variable as $key => $value) { } let me know if anything you need. Thanks


3

Try this Vender/Module/etc/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <preference type="Vender\Module\Block\Product\ListProduct" for="Magento\Catalog\Block\Product\...


3

Add this in your vendor/magento/data-migration-tool/etc/opensource-to-opensource/class-map.xml. Ensure that class-map.xml is specified correctly in config.xml <rename> <from>ultramegamenu/category_attribute_source_dropdown_type</from> <to></to> </rename> Similarly, you can rename all the classes. You can ...


3

The errors are invalid XML There is a plugin for PHPstorm editor https://github.com/magento/magento2-phpstorm-plugin You can then generate XML URN map to validate against. https://magento.stackexchange.com/a/101524/70343 Or better yet you can scan your code. I was going to type an answer on how to use it but then I came across this https://magento....


3

No you cannot pass any data from JS to phtml directly. PHTML is executed at server side while JS is executed at client side. If you wanna pass any data to server you need to use either Ajax or Server request via GET/POST method. Inorder to pass data from controller to phtml you could do this in your execute() $name = $this->getRequest()->getParam('...


3

This occurs Because you can inject Magento\Framework\App\Http in any our class try following steps php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:Deploy -f chmod -R 777 var/ generated/


3

Can you please try to change __autoload function to spl_autoload_register after clear cache and remove var directory /app/code/core/Mage/Core/functions.php on line 60 source Let me know issue resolved with it or not ?


2

I have got solution for my question. For memory exhausted error, we have to add memory limit for compile code. php -dmemory_limit=4G bin/magento setup:di:compile Hope it will help someone in future.


2

You can do this by following steps: Step 1(Adding form in review list.phtml): Create review_product_listajax.xml under below location: app/design/frontend/[Vendor]/[theme]/Magento_Review/layout/review_product_listajax.xml with below content: <?xml version="1.0"?> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...


2

The above error is happening because you are trying to mass delete many products from your Magento admin panel inside a browser. I can suggest you to: 1.) Delete the products in limited number. 2.) Increase your PHP execution time 3.) Write a php script to delete the products from your Magento instance and execute that php script from your command line.


2

This is showing that Class 'CrediYa\CrediYa\Model\CrediYa' is not exist in your module. Also you can check the class namespace whichever it used by CrediYa. so you can find & correct it.


2

You can do it using observer. layout_load_before this event means change layout before the pages load. create etc/event.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name="layout_load_before"> <...


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