23

For adding image field, you can try using plugin and always try to avoid overwrite whole class. Vendor/Module/etc/adminhtml/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"> <type name="Magento\User\Block\User\Edit\...


9

You have to inject \Magento\Framework\App\ProductMetadataInterface into your constructor. protected $productMetadata; public function __construct( ... \Magento\Framework\App\ProductMetadataInterface $productMetadata, ... ) { $this->productMetadata = $productMetadata; parent::__construct(...); } Then you can get current Magento ...


6

First, take a look at this method Magento\Framework\Interception\Interceptor::___callPlugins. this is where the magic happens. (I'll explain why you need to look at this later). Notice that Magento\Framework\Interception\Interceptor is a trait and not a class. So $this inside the trait references the object that has this trait. This method accepts 3 ...


4

You cloned your Magento from Github, so all your core is in folder app/code/Magento/, you need remove it and run the composer command to have your core in the folder vendor/. Note that you shouldn't clone the repository, next time install using Composer. These are the steps that I used to fix: rm -rf var/view_preprocessed/ var/cache/ var/page_cache/ var/...


4

You might have added a di.xml file . <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Catalog\Model\Product"> <plugin name="plugin_update_product_name" type="Inchoo\Custom\Plugins\...


3

You can compare both version from below link https://github.com/magento/magento2/compare/2.1...2.2 Open File Changed tab you can find here all changes related to file structure as well as code changes in files.


3

If I can see this correctly, Mage_Core_Model_App has this constant: const DEFAULT_ERROR_HANDLER = 'mageCoreErrorHandler'; ...which is later registered like this: /** * Initialize PHP environment * * @return Mage_Core_Model_App */ protected function _initEnvironment() { $this->setErrorHandler(self::DEFAULT_ERROR_HANDLER); ...


3

Generally, you shouldn't ever be editing Core (or making any of the other common mistakes new Magento developers often make when attempting to customize / improve performance), if for no other reason than you will not be able to install security patches when released (the patches will only work on unmodified copies of core). Additionally, there's a lot of ...


3

1) Does the Plugin that extend the core Magento module class has to be in the same directory structure as the parent that it extend? For example: No, plugins are stand-alone classes. 2) I am not entirely sure what exactly should I do so MyModule gets invoked when I go to the page ? This question doesn't quite make sense. A plugin is basically a "...


3

Mysql has a limit of 63 joins per query. The 4 remaining are reserved for things like website and category associations.


2

It looks like you installed Magento by cloning the github repository and then tried to upgrade using composer. The problem is that composer places the core modules in the Vendor directory while cloning the repository results in them being in App/Code directory, so now you have duplicates. You should remove the App/Code/Magento directory to solve the error. ...


2

change <company_bnoverride before="Mage_Checkout_Cart">Company_BnOverride</company_bnoverride> to <company_bnoverride before="Mage_Checkout">Company_BnOverride</company_bnoverride>


2

Before doing anything I suggest you create a dev site, like dev.example.com and clone the live website there, so the sales continue on the live website. For the issue you're having, I suggest the following steps: Copy app/code/core to another directory outside the web directory (site_core for example). Download Magento 1.9.1 and copy it's app/code/core to ...


2

Method 1: Use Magento standard way to get version of your site, Using Block - Template way is proper way to do call any function in magento 2, Inside Block file, <?php namespace Vendor\Modulename\Block class Version extends \Magento\Framework\View\Element\Template{ protected $_productMetadata; public function __construct( \Magento\...


2

The short answer is that the second parameter expects a field name that you want to load the product by. This allows you to load it by something other than just id, but it defaults to the id if nothing is provided. More information is below if you want details: If you look in the module "sales/order" in app/code/core/Mage/Sales/Model/Order.php you'll ...


2

you need to add in the di.xml file of your module this <preference for="Magento\Catalog\Block\Adminhtml\Product\Edit" type="MyVendor\MyModule\Block\Adminhtml\Product\MyEdit" /> This will tell Magento to use your class instead of the core one.


2

The plugin is probably cached by redis. Flush your redis cache using the following command: redis-cli flushall


2

Replacing the statement return parent::_prepareForm(); with this return \Magento\Backend\Block\Widget\Form\Generic::_prepareForm(); worked for me. Here is the complete code. Adding the field "Accessible Store" as follow. <?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ // @...


2

after some research got a solution for this add new property "value" in addField method with the value you need. see the example: $fieldset->addField( 'user_image', 'image', [ 'name' => 'user_image', 'label' => __('Image'), 'id' => 'user_image', ...


1

It is a new feature in PHP 7 called Return type declarations. Return type declarations specify the type of the value that will be returned from a function. The same types are available for return type declarations as are available for argument type declarations. Relevant for your given code ; When overriding a parent method, the child's method ...


1

now() isn't actually part of the 'core' helper. It is a method inside of the app/code/local/Mage/Core/functions.php file that gets included in app/Mage.php like this: include_once "Mage/Core/functions.php"; The correct way to call this would be: echo now(); You don't need the Mage::helper('core') part since it's not actually part of the core helper and ...


1

Just to add another working example, I've succeeded in overwriting the Website admin page. I was trying to add a URL field to the website edit page. I did exactly what it's said in the validated answer but I didn't add a new fieldset. Instead, I've completed the existing one, using it's id defined in the Website class. Besides, I'v used the inheritance to ...


1

I used to do e-commerce sites where I had to migrate homemade shopping cart systems and migrate existing inventory and sales data from it into Magento. I can say I learned a lot this way! Like most systems, coding languages and frameworks, I think the best way to learn Magento is by doing Magento projects. Make a project up, do tutorials, customize ...


1

If you edit these files, you do edit a core file. When upgrading Magento to a new version or sometimes when patching, this file might be overridden. What you could do is create a custom extension and set a custom template for that page. That's what I normally do, so I'd try that if I were you. Another option might be that Inchoo created an extension (see: ...


1

The Magento Core team only have put Magento2 onto a public repository so the only way you can try and put in a pull request for a bug in the 1.x range would be to submit a bug report. https://www.magentocommerce.com/bug-tracking


1

Definitively, in any framework it is a bad idea to modify core files. There is almost always some way to override native code. There are many reasons, the two main being: The risk to create side-effects on other modules The risk to see your modification wiped out when you update the framework Regards


1

Magento already supports this out of the box. It is called layered navigation. For category lists (where the categories are marked as "Is anchor" => 'Yes') and search results this happens automatically. In order to have an attribute appear in the layered navigation, you need to mark it accordingly, by editing the attribute in the backend and setting the ...


1

You can simply copy core file (which you want to override) and paste it in app/code/local/Mage maintaining the same path of that php file. Then you can start editing this file, magento will read your file instead of the core file. Below is an example : => If you would like to override app/code/core/Mage/Catalog/Block/Product.php you need simply need it to ...


1

Can't you just strip the html in the head.phtml template instead of overriding a class method? Off the top of my head you probably should look at Mage_Page_ Block_Head if you want to override that method


1

Here first you need to put your work live server as you are planning then update Magento. In this case if you didn't make the changes inside the core file and templates, it will work fine. If you have changes in code then your changes will not be there after magento update. So you need to work on those changes again and this time remember never make changes ...


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