PrestaShop 1.7 override src file in own module - php

I create own module and I want to override some file so in views folder I create folder PrestaShop and in it I add complete path to file like Admin/Catalog/Product/List/somefile.php and this override works, but when I want override file from src folder there is nothing happend. For example I want to override file public_html/src/Adapter/Product/PriceCalculator.php so in my module I have public_html/modules/mycustommodule/views/PrestaShop/src/Adapter/Product/PriceCalculator.php and this is not work. There is any possibility to override those files?

I think that is not possible to override this folder, you can't overrides of other things than classes/controllers/modules with /override/ directory is not available anymore.
You can reed informations about that in their post : planned to ovverride

Related

Magento2 : How can override vendor/module-catalog to magento default theme?

I am trying to override vendor/magento/module-catalog/* ( * for whole module ).
I copied,
vendor/magento/module-catalog/view/templates/*
files under
app/design/frontend/Magento/Magento_Catalog/*
But I can't get any change of copied files. I don't have any custom theme.
How can I do this? I want to keep original files unchanged with my custom changes.
You can override all files from vendor to our theme using below method.
Goto vendor\magento\module-catalog\view\frontend
Copy all folders and files to
app\design\frontend\{Your_vendor}\{Theme_name}\Magento_Catalog
Clear your cache using below command.
php bin/magento cache:clean
Refresh your page you can see files from your theme.
You can use this as a theme.
app/design/frontend/Magento/Magento_Catalog/
First, you have to create your own theme containing folder like:
app/design/frontend/Mytheme/Theme/Magento_Catalog
And select the theme from admin.
Then this folder will override core module_catalog

Override Prestashop 1.6.1.4

I am doing a module in Prestashop and I need override the method update in the class CartCore. I have created a class inside the folder override (I have tried in modules/name_of_module/override also) Cart extends CartCore (the file is Cart.php), and I have the next code.
public function update($null_values = false, $hook = true)
{
if (isset(self::$_nbProducts[$this->id])) {
unset(self::$_nbProducts[$this->id]);
}
if (isset(self::$_totalWeight[$this->id])) {
unset(self::$_totalWeight[$this->id]);
}
$this->_products = null;
$return = parent::update($null_values);
if($hook) Hook::exec('actionCartSave');
return $return;
}
I have deleted the file cache/class_index.php and I have activated the overrides in the back-office Performance but it does not work. Only works if I change the original Cart class, but I donĀ“t want do this.
Thanks!
When you create a new Override in a module Prestashop isn't aware of this new file. Deleting the /cache/class_index.php will only force Prestashop to look for new files in the root /overrides/ folder but not in your module /modules/your_module/overrides/ folder.
Your file needs to be placed under the root /overrides/ folder. This process is done automatically when you install your module. Every override files in your module is placed under the root /overrides/ folder. If you create a new override while your module is already installed, Prestashop will not move it for you.
You then have two possibilities. Uninstall and install your module. Or copying this file into the root /overrides/ folder and deleting the /cache/class_index.php file.
Also take into account Niclas Larsson advise to put this file under /overrides/classes/Cart.php.
Overriding default behaviors
Overriding a class
In order to override the Product class, your file needs to be called Product.php and must feature a Product class that then extends ProductCore class.
The file can be placed in either of these locations:
/override/classes/Product.php
/modules/my_module/override/classes/Product.php
Override files a separated in folders based on their types (classes, controllers, modules, ..)
So i think you are doing things right, but you need to add the folder 'classes' in override, and move your file into it.

How to override this WordPress plugin template file

So in plugins/yith-woocommerce-ajax-search/templates/yith-woocommerce-ajax-search.php, there is a line I want to change in the label, from "Search for:" to "Search". If I change it in this file, it's fine, but of course I want to keep the change in my own theme rather than modify it here.
So, I copied the entire plugin folder over into my theme folder and made the change, but it's not working. The path is themes/MYTHEME/yith-woocommerce-ajax-search/templates/yith-woocommerce-ajax-search.php
Any clues why this isn't working?
The plugin uses wc_get_template() to load yith-woocommerce-ajax-search.php. This means that you can put the template file directly in the themes/YOURTHEME/woocommerce/ directory, then your template should be loaded correctly.

override wedevs-dokan-plugin template file from theme wordpress

I'm using the wedevs-dokan-plugin (wedevs.com/dokan) for a WordPress frontend user store, which allows sellers to manage their store from the frontend.
I want to override one of the template files of this plugin. The file which I want to override is located at:
plugins/wedevs-dokan-plugin/templates/product-edit.php
And to override this file, I copied the file and made some changes, putting this new file in the theme directory like this:
themes/mytheme/wedevs-dokan-plugin/product-edit.php
But this isn't working for me. After that I also tried:
themes/mytheme/wedevs-dokan-plugin/templates/product-edit.php
But that's also not working.
Is there any way to override the plugin files from within a WordPress theme?
themes/mytheme/wedevs-dokan-plugin/product-edit.php
Instead of "wedevs-dokan-plugin" the directory name should be "dokan" and you can only edit the "templates" directory files of this plugin.
So, the new directory will look like these.
themes/mytheme/dokan/store.php
themes/mytheme/dokan/dashboard/dashboard.php
Thanks

Symfony editing admin views

I work on existing symfony project and I want to change something in view in admin (backend app) which is automatically generated. I found that I can change views in /lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/...
I think it is not good idea to edit this files. How can I change these templates?
You can override the template at the module level. After visiting the page in question look in the cache directory and check out the autogenerated code there for example:
cache/
backend/
modules/
/autoMyModule/
templates/
You can then figure out which file it is you need to change and then create that file in apps/backend/myModule/templates and override what you need.

Categories