Schlagwort-Archive: MySQL

Alle Preise in Woocommerce ändern – auf die smarte Art

Wer schon einmal nach dem Schlüsselwort price in einem Datenbankdump von Woocommerce und WordPress gesucht hat, weil er seine Artikelpreise gerne auf einen Schlag ändern möchte, der wird einfach nur verzweifeln.

Es gibt allein in wp_post_meta 12 Möglichkeiten, Preise einzugeben. Und das ist noch nicht einmal alles.

Annahme: Wir wollen unsere Preise einer Inflation von 2 Prozent anpassen. Wie geht man vor?

Tabelle wp_postmeta

UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_regular_price' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_sale_price' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_price' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_regular_price_tmp' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_sale_price_tmp' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_price_tmp' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_min_variation_price' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_max_variation_price' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_min_variation_regular_price' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_max_variation_regular_price' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_min_variation_sale_price' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*1.02 WHERE meta_key = '_max_variation_sale_price' AND meta_value != ''

Tabelle wp_options

DELETE FROM wp_options WHERE (option_name LIKE '_transient_wc_var_prices_%' OR option_name LIKE '_transient_timeout_wc_var_prices_%')

Die letzte Zeile ist besonders wichtig, da Woocommerce  einen Transient-Cache nutzt, um Seiten schneller darstellen zu können. Indem man diesen Speicher auf einen Schlag löscht, wird er automatisch beim nächsten Aufruf eines Produktes neu generiert.

Copy MySQL tables across different servers with PHP

How to copy table1 from host1 to host2:

<?php
set_time_limit(0);
ini_set('memory_limit', '-1');
$execstring="mysqldump -h host1 -u user1 -ppassword1 databasename TblName | mysql -h host2 -u user2 -ppassword2 anotherDatabase";
$output="";
exec($execstring, $output);
?>

 

Aware: all the values after pipe (|) must not contain special characters (e.g. !) as they are interpreted by the bash. So escape them.

Backup source and target before testing.

Test: dbForge Studio for MySQL

With the help of dbForge Studio for MySQL I was finally able to export all my large Excel, CVS and Access data which I use for my selling reports to my MySQL Online Database without any losses.

dbForge Studio for MySQL is a VERY smart product which e.g. automatically detected and converted the right column type (datetime) from a CSV! Non of the other programs I tested was able to do the same. (PhpMyAdmin, HeidiSQL, Oracle Workbench all failed with corrupt data)

dbForge Studio for MySQL

I strongly recommend this tool to everyone who needs to work with MySQL

More information: https://www.devart.com/de/dbforge/mysql/studio/

WordPress plugin: Display SQL Stats

Displaying SQL result data as graphical chart on the dashboard with use of Google Chart Tools.

Showing chart in dashboard

Showing chart in dashboard

Settings

Settings

Download from WordPress repository.

Changelog

0.7 (2014/02/05)

  • adding/removing SQL statements more stylish

0.6.5 (2013/12/27)

  • fix bug on automatic detection of column types
  • better formatting of debug information

0.6.4 (2013/11/08)

  • only enrich header when on dashboard

0.6.3.1 (2013/10/17)

  • fixing small bug on min/max values when using more than one barcharts

0.6.3 (2013/10/15)

  • placing automatic max/min values on barcharts for better visualisation

0.6.2 (2013/09/14)

  • bug fix on emtpy results
  • switch charts on/off

0.6.1 (2013/09/14)

  • bug fix on wrong date display

0.6 (2013/09/14)

  • Check on WordPress 3.6.1
  • New chart types: Bar Chart
  • auto detecting of column types: date, number, string

0.5 (2013/09/10)

  • Use different chart types (Pie Chart, Scatter Chart, Bubble Chart)

0.4 (2013/08/21)

  • Use multiple SQL statments and charts

 0.3 (2013/08/17)

  • Tested with WP 3.6
  • New default demo SQL to demonstrate how to insert additional columns

0.2 (2013/04/25)

  • NEW: Notepad function to store different SQL statement, ideas or whatever

0.1 (2013/04/16)

  • first test version

Quick: SquirrelMail und XAMPP lokal installieren und testen

Quick: SquirrelMail und XAMPP lokal installieren und testen

Wer Applikationen programmiert, die auch Mails verschicken, möchte dies natürlich auch lokal testen. Dazu lohnt es sich, den Webmail Client »SquirrelMail« zu installieren. Dieser Artikel ergänzt mein XAMPP-Tutorial.

1. laden http://squirrelmail.org/download.php

2. entpacken nach »c:\Programme\xampp\htdocs\squirrelmail\« und anlegen von »c:\Programme\xampp\htdocs\squirrelmail\attach\«

3. kopieren der Konfigurationsvorlage »c:\Programme\xampp\htdocs\squirrelmail\config\config_default.php« nach »c:\Programme\xampp\htdocs\squirrelmail\config\config.php«

4. editieren von »c:\Programme\xampp\htdocs\squirrelmail\config\config.php«


$domain = 'localhost';

$data_dir = 'c:\\Programme\\xampp\\htdocs\\squirrelmail\\data\\';

$attachment_dir = 'c:\\Programme\\xampp\\htdocs\\squirrelmail\\attach\\';

$imapServerAddress = 'localhost';

$smtpServerAddress = 'localhost';

5. Testen

User anlegen in Mercury. In der Admin-Oberfläche: Configuration|Manage Local Users…|Add einen User anlegen. User in Mercury meint die eigentlichen Mail-Empfänger.

Einwählen: http://localhost/squirrelmail/src/login.php

Name: Username (ohne @localhost)

Passwort: (wie festgelegt)

Mail zusenden: http://localhost/xampp/mailform.php (Adressat=Ihr neuer Nutzer PLUS @locahost). Die Mail müsste augenblicklich in SquirrelMail erscheinen, eventuell müssen Sie noch »Check mail« klicken.