Joomla plugin install file - joomla

Is it possible in joomla install.xml file write some sql, which would be executed on install? Or somehow else do this trick? The point is that i have written custom authorization plug-and i have to disable/replace/delete an existing one.

You could use external SQL-files and make them execute on install.
1. Create a SQL-file install.mysql.utf8.sql in your plugin root with some content like:
CREATE TABLE IF NOT EXISTS `#__tablename` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;
2. In your XML-manifest add the file as a filename node underneath files:
<files>
<filename>install.mysql.utf8.sql</filename>
</files>
3. Add a install node in your manifest that tells Joomla what SQL file to execute on installation:
<install>
<sql>
<file driver="mysql" charset="utf8">install.mysql.utf8.sql</file>
</sql>
</install>
If you install the plugin with this and it's a new installation (the plugin havn't been installed on the site before) then Joomla will execute the SQL-file.
If you need to execute SQL on a upgrade (reinstallation) of the plugin you'd have to use the update node.
An alternative to SQL-files is to use PHP-scripts to be executed (which can run SQL queries themselves) on install/update. For help with that, see this.

Related

Magento 1.14.2.1 to Magento 2.3.2 from CLI

I am trying to migrate website from Magento 1.14.2.1 to Magento 2.3.2 using Ubuntu commands. I have made all changes on config.xml file with path to both database and here is the command i am trying to execute to apply settings
xxx$bin/magento migrate:settings -r vendor/magento/data-migration-tool/etc/commerce-to-commerce/1.14.2.1/config.xml
it returns the following error
In Dom.php line 455:
EntityRef: expecting ';'
Line: 133
migrate:settings [-r|--reset] [-a|--auto] [--] <config>
i have tried this as well
xxx$bin/magento migrate:settings -reset vendor/magento/data-migration-tool/etc/commerce-to-commerce/1.14.2.1/config.xml
Tried internet but found no help on it, would be great if someone suggest the fix for this error.
You are not able to update magento 1 to magento2 just from command line.
You have to make a whole of data migration.
Magneto has some migration tools also :
https://devdocs.magento.com/guides/v2.3/migration/migration-tool.html

WIX Change Product Name and Install directory from command line parameters

I ran into a typical scenario where it required to change product name as supplied from command line parameters as below
MSBuild.exe ApplicationSetup.wixproj /p:AssemblyTitle=%USER_SPECIFIED_NAME% /p:ProductVersion=%VERSION% /p:ProductCode=%PRODUCT_CODE% /p:UpgradeCode=%UPGRADE_CODE% /t:Clean;Rebuild"
I am using those supplied parameters in .wxi file. as below :
<Product Id="$(var.ProductCode)" Name="$(var.AssemblyTitle)" Language="4"
Version="$(var.BuildVersion)"
Manufacturer="!(loc.Manufacturer)" UpgradeCode="$(var.UpgradeCode)">
This code compiles successfully. But the name of product in add/remove program is not reflecting correctly. I read that Product name cannot be supplied directly, it should be hard coded.Please advise on this.
Another typical requirement is to have multiple version installed of same product on a machine. I somewhat achieved this by doing following change in Product tag in .wxi file
<Product Id="*" Name="$(var.AssemblyTitle)" Language="4"
Version="$(var.BuildVersion)"
Manufacturer="!(loc.Manufacturer)" UpgradeCode="$(var.UpgradeCode)">
Now here come the issue that second installation will overwrite the file generated during first installation. So it is required to change install directory dynamically.
I have posted this after struggling for couple of days and tried many solution, but all in vain. Any help will be highly appreciated.

joomla create component with creation of 2 tables

I try to create 2 tables for a component I m writing for joomla. I have in the xml file:
<install> <!-- Runs on install -->
<sql>
<file driver="mysql" charset="utf8">sql/install1.mysql.utf8.sql</file>
</sql>
<sql>
<file driver="mysql" charset="utf8">sql/install2.mysql.utf8.sql</file>
</sql>
</install>
But it installs only the first file hence the first table. And if I put all the sql commands in one line I get an error from joomla:
JInstaller: :Install: Cannot find Joomla XML setup file
What am i doing wrong?
Thanks for the help,
John.
Ok,
I found the problem. In fact, I was using the wrong collation in my database :(

How do I revert from generate:resource while using JeffreyWay/Laravel-4-Generators?

How do I revert from generate:resource while using JeffreyWay/Laravel-4-Generators ?
Is there a shortcut to remove the installed resource through a command, something like the inverse of the statement below ?
php artisan generate:resource post --fields="title:string, body:text"
I have successfully installed & created a resource using the generator in https://github.com/JeffreyWay/Laravel-4-Generators and watching the tutsplus video https://tutsplus.com/lesson/running-migrations/
There is no shortcut - you need to remove the files manually. If you are using Git (or similar version control) you can just 'roll back'.
Otherwise you need to delete:
Post Migration table creation
Model/Post.php
Views/Posts/*
Controllers/PostController
Seeds/PostsTableSeeder.php
Tests/Controllers/PostsControllerTest.php
Remove postseeding from databaseseeder.php
Update routes.php to remove Route::resource('posts');

After using my new magento module: SQLSTATE[42S02]: Base table or view not found: 1146 Table XXX does

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'desbest_full2.showdown_matches' doesn't exist
But why, if I've got a mysql setup script inside app/code/local/Desbest/Showdown/sql/Showdown_setup/mysql4-install-1.php
<?php
echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n"; die("Exit for now");
$installer = $this;
/* #var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
$installer->startSetup();
$installer->run("
CREATE TABLE {$this->getTable('showdown_matches')} (
--CREATE TABLE IF NOT EXISTS `showdown_matches` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`firstproductid` int(11) NOT NULL,
`secondproductid` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
`datenumber` varchar(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8_general_ci AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `showdown_votes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`matchid` int(11) NOT NULL,
`votedfor` varchar(10) NOT NULL,
`ip` varchar(50) NOT NULL,
`datenumber` varchar(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8_general_ci AUTO_INCREMENT=1 ;
");
$installer->endSetup();
The module worked on my original Magento installation.
It is possible that your setup script is not running because Magento thinks it has already been run. You can check the database table core_resource for a record for your module with the modules version. This resource record is how Magento knows if it has already run a modules setup scripts, or determines if it needs to run an upgrade script from an older version to a newer one.
If you delete the record for your module from the core_resource table Magento will attempt to execute your setup script the next time Magento generates a page.
I would also expect that you'd need to remove the die("Exit for now"); from the setup script so that it actually reaches the part where it creates the tables. If the setup script launches and calls the die() function and ends the execution of that script, I think it might go ahead and create the core_resource record indicating it's completed the setup script and won't run it again unless you remove that record from the core_resource table.
You can find some information about setup scripts in the Magento Knowledge Base:
Magento for Developers: Part 6 - Magento Setup Resources
You might also check the module config XML file to make sure the version there matches the version of the setup script's file name.
<modules>
<Desbest_Showdown>
<version>1</version>
</Desbest_Showdown>
</modules>
<global>
<resources>
<showdown_setup>
<setup>
<module>Desbest_Showdown</module>
</setup>
</showdown_setup>
</resources>
</global>
Another thing I thought of is file/directory name case sensitivity. If you setup a bunch of stuff on a Mac where you have a case insensitive file system everything works fine, and then move files to a linux box where the file system is case sensitive you'll have issues with files not getting found. You listed your filename as app/code/local/Desbest/Showdown/sql/Showdown_setup/mysql4-install-1.php and I think the directory Showdown_setup may need to be all lowercase showdown_setup.
There's steps in this question for debugging non-running setup resource scripts.

Resources