2

I want to add some custom text test to my mini top cart in my theme header section. I see it is located here:

public_html/m2/vendor/magento/module-checkout/view/frontend/templates/cart/minicart.phtml

When I edit this file and clear cache I can see my test showing on the site fine,

However a friend of mine told me I should not be editing files located in /vendor directory

So if I wanted to add my minicar.phtml with my own text inside this where would I add this file in my theme ? which directory would override me needing to edit any files in vendor?

Thanks

2 Answers 2

2

Explanation:

Yes, rule number 1, you must never update a native magento folders why ? there are several reasons and the most common is : if one day you have to update your Magento or install some patch you will have errors and you lose your updates because you have updated that files ! and you need to do that manually one by one and it's not practical !

Solution:

To update some files from a native Magento modules you can either rewrite the module or either updating it in the current theme. And since you want just to update a phtml file so the best way is to override it in your current theme.

So you copy your file from:

vendor/magento/module-checkout/view/frontend/templates/cart/minicart.phtml

to:

app/design/frontend/{YourVendorName}/{YourThemeName}/Magento_Checkout/templates/cart/minicart.phtml

Dont forget to clean the cache and deploy the static-content by launching these commands:

php bin/magento cache:clean

php bin/magento setup:static-content:deploy -f
1

Chances are, you'll want to set up a theme if you haven't already. Here is some information on that. For now, I will assume that you are using the Luma theme, but you can replace the Magento/Luma/ part of the path with [vendor]/[theme] once you have created a theme folder. Copy the file that you found under vendor/.. to the location below and edit away!

/app/design/frontend/Magento/Luma/Magento_Checkout/templates/cart/minicart.phtml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.