Activate two add-ons on prestashop - prestashop-1.7

I want to activate two add-ons on prestashop but i cant activate both i get this error
Cannot enable module blockproductsbycountry. Unable to install override: The method getProductProperties in the class Product is already overridden by the module dynamicproduct
the path
public_html/override/classes/Product.php
provider->isAfter1730()) { $id_product = (int) $row['id_product']; $dynamic_config = classes\models\DynamicConfig::getByProduct($id_product); if ($dynamic_config->active) { $displayed_price = classes\models\DynamicConfig::getDisplayedPrice($id_product); if ($displayed_price || $dynamic_config->display_dynamic_price) { $module->calculator->assignProductPrices($row, $displayed_price, $result); } } } return $result; } }

This happens when a method of a class is overriden by both modules at the same time.
There is no automatic solution for this: you will have to check both overrides and manually merge the code back into the main Prestashop folder (/override/classes/Product.php).
After that you will have to remove the overridden method from the installer of both modules so that you can install/activate/deactivate them as needed without having errors.

Related

Jetpack Compose - Room database not able to read from flow on release build

I'm performing an action on an item and using the copy function to update its value in room database. It works as intended in debug version (the text changes color/value) but in release build it doesn't. It still works, I just don't see it reflects right away. If I navigate away from tab and back I can see the state updates. Why it doesn't behave the same on release build? How would you go by to debug this?
//updating in ViewModel
repository.updateIsDisconnected(devices.copy(isDisconnected = true))
//getting * from db
val getItems = vm.getItems.collectAsState(initial = emptyList())
//Presenting Lazycolumn
LazyColumn() {
items(getItems.value) { item ->
Row(){
//Text that is suppose to be updated
if (item.isDisconnected) Text(text = "Disconnected", color = Color.Green)
else Text(text = "Found", color = Color.Gray)
}
}
}
I'm suspecting it has to do with ProGuard and I've added the following but still the same:
-keep class * extends androidx.room.RoomDatabase
-keep #androidx.room.Entity class *
-dontwarn androidx.room.paging.**

How to set newRecordStoragePid for TYPO3 extension modules?

How can I set newRecordStoragePid for TYPO3 extension modules (BE part of the extension)? I've tried the following setting:
module.tx_dscontrolpanel_web_dscontrolpaneldscontrolpanel {
persistence {
storagePid = 0
classes {
DS\Dscontrolpanel\Domain\Model\Entitymodulelist{
newRecordStoragePid = 0
}
}
}
view {
templateRootPaths.0 = EXT:dscontrolpanel/Resources/Private/Templates/
partialRootPaths.0 = EXT:dscontrolpanel/Resources/Private/Partials/
layoutRootPaths.0 = EXT:dscontrolpanel/Resources/Private/Layouts/
}
But it only takes the pid of the chosen page in the page tree. Is this setting even available for the BE? Is there a diffrent 'clean' way to set the pid for new objects in TYPO3 backend?
I've forgot to include the static template of my extension. Now everything works as expected.

Silverstripe - Turn modules on or off in config

Is it possible to activate or deactivate modules based on entries in either config.yml or _config.php?
Say I've built an Image Gallery module but don't want it showing on the site yet, can it be deactivated in the config files?
Only if the module has provided functionality to do so.
You can add your own private static $enable_module = true
class MyClass extends Object
{
private static $enable_module = true;
public function doMyThing()
{
if (!Config::inst()->forClass('MyClass')->enable_module) {
return false;
}
// do stuff here
}
}
then you can disable it via YML
MyClass:
enable_module: false
would disable it.
For templates you could add
public function getGalleryEnabled() {
return Config::inst()->forClass('MyClass')->enable_module;
}
to your Page_Controller class and then
<% if $GalleryEnabled %><% include MyGallery %><% end_if %>
The best practice is: never develop on the live site
SilverStripe scans all directories in webroot for modules. If you place a file called manifest_exclude in any directory, it won't be scanned and not included; the autoloader won't find it and you cannot call your class without including the file manually.

grails 2.2.2 platform-core-plugin No signature of method event in domain model

I try out the platform-core-1.0 rc5 Plugin to services by events. Now I write a service in the grails-plugin "listadmin":
package listadmin
class SECO_ListenService {
#grails.events.Listener(topic='getEntriesOfList', namespace='listadmin')
def getEntriesOfList(String intnalListName) {
println "SECO_ListenService"
def Liste aList = Liste.findByInternal_name(intnalListName)
return aList.eintrage.toList()
}
}
This service should return a list for dropdown in an other grails-plugin called "institutionadmin". I want to use this list of the service for a dropdown of a domain-model. I should mention that I use dynamic scaffolding. Now I try to call this event in the domain-model:
package institutionadmin
import org.springframework.dao.DataIntegrityViolationException
class Einrichtung {
Long einrichtungs_type
Long type_of_conzept
int anzahl_gruppen
int anzahl_kinder_pro_Gruppe
String offnungszeiten
static hasMany = [rooms : Raum]
static constraints = {
def aList = []
def reply = event(for:"listadmin", topic:"getEntriesOfList", data:"einrichtung_type").waitFor()
aList = reply.value.toList()
einrichtungs_type(inList: aList)
}
}
If I try to run this application i get the following error:
Caused by MissingMethodException: No signature of method: institutionadmin.Einrichtung.event() is applicable for argument types: (java.util.LinkedHashMap) values: [[for:listadmin, topic:testEventBus]]
Possible solutions: ident(), every(), every(groovy.lang.Closure), count(), get(java.io.Serializable), print(java.lang.Object)
If call this event in a controller everything is fine and the documentation of this plugin describe that I can call events also in domain-models and services... This error-method tell me, that the class don't know the event method.
Do I have to configure anything else?
Should call the event in another way or where is my mistake?
Has anybody experiences with this module?
The event(...) dynamic methods are not available on class (static) level.
You can pull the grailsEvents spring bean and call its event() method alternatively. You still have to get the bean from the application context statically though.
You could also use a custom validator instead, as you can get the current domain instance as a parameter, which should have the event() method injected.
something like this :
static myList = []
static constraints = {
einrichtungs_type validator: { value, instance ->
if(!myList){
// cache it the first time you save/validate the domain
// I would probably recommend you NOT to do this here though in
// real life scenario
def reply = instance.event('blabla').get()
myList = reply.value.toList()
}
return value in myList
}
}
Anyway, In my case I would probably load the list elsewhere (in the Bootstrap.groovy for instance) and use it / inject it in my domain instead of doing in the constraints closure.
I faced similar kind of problem, I wanted to use the event call inside a service class which is going to call the listener in other service class. When I started my application I got the same error.What I did was, added the plugin(platform-core:1.0.RC5) entries in BuildConfig.groovy like below
plugins {
build(":tomcat:$grailsVersion",
":platform-core:1.0.RC5") {
export = false
}
compile ':platform-core:1.0.RC5'
runtime ':platform-core:1.0.RC5'
}
Then I ran grails > clean and grails > compile on that project and restarted the server.It started working. Might be you can give a try.

Environment-specific web.xml in grails?

What's the best way to build environment-specific web.xml entries in grails?
I need to make certain modifications for production only, as they break running locally.
Any thoughts?
You can create scripts/_Events.groovy with an event handler for the 'WebXmlEnd' event which is fired once Grails and the plugins have finished making their changes. Update the XML with plain search/replace or via DOM methods by parsing the XML and write out the updated file:
import grails.util.Environment
eventWebXmlEnd = { String filename ->
if (Environment.current != Environment.PRODUCTION) {
return
}
String content = webXmlFile.text
// update the XML
content = ...
webXmlFile.withWriter { file -> file << content }
}
Here's the solution that's i'm using, from the guy over at death-head.ch
first install the templates
grails install-templates
then customize the web.xml you'll find in src/templates/war/web.xml. I chose to make a web_dev.xml and a web_prod.xml and delete the web.xml. I wanted web_prod.xml to contain a security-constraint block. anyway...
Place the following in BuildConfig.groovy:
// #########################################################
// ## Can't use environment switching block because BuildConfig doesn't support it.
// ## #url http://jira.grails.org/browse/GRAILS-4260
// ## So use this workaround:
// ## #url http://death-head.ch/blog/2010/09/finally-solved-the-base-authentication-in-grails/
// #########################################################
switch ("${System.getProperty('grails.env')}") {
case "development":
if (new File("/${basedir}/src/templates/war/web_dev.xml").exists()) {
grails.config.base.webXml = "file:${basedir}/src/templates/war/web_dev.xml"
}
break;
default:
if (new File("/${basedir}/src/templates/war/web_prod.xml").exists()) {
grails.config.base.webXml = "file:${basedir}/src/templates/war/web_prod.xml"
}
break;
}
Good luck!
I've never tried it, but it should be possible to specify the grails.config.base.webXml parameter in BuildConfig.groovy dependant on the current environment.
There's a list of available BuildConfig settings here
EDIT
Actually, due to this issue, this isn't a way forward :-( Maybe passing the property like:
grails -Dgrails.config.base.webXml=/path/to/web.xml
Is all that's possible?

Resources