Wipe all products from magento database
Here's a sql snippet that deletes all the products from a mysql database:
TRUNCATE TABLE `catalog_product_bundle_option`; TRUNCATE TABLE `catalog_product_bundle_option_value`; TRUNCATE TABLE `catalog_product_bundle_selection`; TRUNCATE TABLE `catalog_product_entity_datetime`; TRUNCATE TABLE `catalog_product_entity_decimal`; TRUNCATE TABLE `catalog_product_entity_gallery`; TRUNCATE TABLE `catalog_product_entity_int`; TRUNCATE TABLE `catalog_product_entity_media_gallery`; TRUNCATE TABLE `catalog_product_entity_media_gallery_value`; TRUNCATE TABLE `catalog_product_entity_text`; TRUNCATE TABLE `catalog_product_entity_tier_price`; TRUNCATE TABLE `catalog_product_entity_varchar`; TRUNCATE TABLE `catalog_product_link`; TRUNCATE TABLE `catalog_product_link_attribute`; TRUNCATE TABLE `catalog_product_link_attribute_decimal`; TRUNCATE TABLE `catalog_product_link_attribute_int`; TRUNCATE TABLE `catalog_product_link_attribute_varchar`; TRUNCATE TABLE `catalog_product_link_type`; TRUNCATE TABLE `catalog_product_option`; TRUNCATE TABLE `catalog_product_option_price`; TRUNCATE TABLE `catalog_product_option_title`; TRUNCATE TABLE `catalog_product_option_type_price`; TRUNCATE TABLE `catalog_product_option_type_title`; TRUNCATE TABLE `catalog_product_option_type_value`; TRUNCATE TABLE `catalog_product_super_attribute`; TRUNCATE TABLE `catalog_product_super_attribute_label`; TRUNCATE TABLE `catalog_product_super_attribute_pricing`; TRUNCATE TABLE `catalog_product_super_link`; TRUNCATE TABLE `catalog_product_enabled_index`; TRUNCATE TABLE `catalog_product_website`; TRUNCATE TABLE `catalog_product_entity`; TRUNCATE TABLE `cataloginventory_stock`; TRUNCATE TABLE `cataloginventory_stock_item`; TRUNCATE TABLE `cataloginventory_stock_status`; insert into `catalog_product_link_type`(`link_type_id`,`code`) values (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell'); insert into `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) values (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal'); insert into `cataloginventory_stock`(`stock_id`,`stock_name`) values (1,'Default');
CD Emulation in Linux
In Linux, most of the time you don't need any special tool to mount an image. You can just mount an .iso file using the mount tool:
sudo mount -oloop Image.iso /mnt
Unfortunately if you want to play a game that needs the CD inside the drive, mounting using the mount tool won't make the CD available for the game (unless it didn't worked for me). So i looked around and found that CDEmu can do the job. To install on Ubuntu add the repos from ppa:cdemu/ppa them install:
sudo add-apt-repository ppa:cdemu/ppa sudo apt-get update sudo apt-get install gcdemu
This will install and applet which you can use with your Gnome panel, and all the other libs that it needs. In order for the applet to work you need to start the cdemud daemon, which depends on the vhba kernel module. To start those run:
sudo modprobe vhba; cdemud &
Now you can mount images using your CDEmu applet
Fix php base64_decode error
If the base64_decode() returns weird results, you might try to decode a string which is not base64 valid. The most common problem seems to be + being replaced with a space (" ") when sending the encoded string via $_POST or $_GET.
To fix that simply do a str_replace on the encoded string, then try to decode it:
$encodedMessages = str_replace(' ', '+', $encodedMessages);
echo base64_decode($encodedMessages);
Hope this will help someone, it took me several hours to figure it out.
Install Adobe® Flash® Player “Square” on Linux
Adobe® Flash® Player "Square" is a preview release that enables native 64-bit support on Linux, Mac OS, and Windows operating systems, as well as enhanced support for Microsoft Internet Explorer 9 beta.
I'm glad to see Adobe has is finally embracing the way it should the 64 bit Platform. This release is a milestone as far as i know, as is the first one that's released in the same time for win, mac and linux. I've put together a small tutorial on
how to install adobe flash player square on linux:
#!/bin/bash # Script created by # Romeo-Adrian Cioaba romeo.cioaba@spotonearth.com echo "Stopping any Firefox that might be running" sudo killall -9 firefox echo "Removing any other flash plugin previously installed:" sudo apt-get remove -y --purge flashplugin-nonfree gnash gnash-common mozilla-plugin-gnash swfdec-mozilla libflashsupport nspluginwrapper sudo rm -f /usr/lib/mozilla/plugins/*flash* sudo rm -f ~/.mozilla/plugins/*flash* sudo rm -f /usr/lib/firefox/plugins/*flash* sudo rm -f /usr/lib/firefox-addons/plugins/*flash* sudo rm -rfd /usr/lib/nspluginwrapper echo "Installing Flash Player Square" cd ~ # 64 bit wget http://download.macromedia.com/pub/labs/flashplayer10/flashplayer_square_p1_64bit_linux_091510.tar.gz tar zxvf flashplayer_square_p1_64bit_linux_091510.tar.gz # 32 bit # wget http://download.macromedia.com/pub/labs/flashplayer10/flashplayer_square_p1_32bit_linux_091510.tar.gz # tar zxvf flashplayer_square_p1_32bit_linux_091510.tar.gz sudo cp libflashplayer.so /usr/lib/mozilla/plugins/ echo "Linking the libraries so Firefox and apps depending on XULRunner (vuze, liferea, rsswol) can find it." sudo ln -sf /usr/lib/mozilla/plugins/libflashplayer.so /usr/lib/firefox-addons/plugins/ sudo ln -sf /usr/lib/mozilla/plugins/libflashplayer.so /usr/lib/xulrunner-addons/plugins/ # now doing some cleaning up: sudo rm -rf libflashplayer.so sudo rm -rf flashplayer_square_p1_64bit_linux_091510.tar.gz
To check if the install did it's job, you need to check about:plugins in your address bar. It should show you this for flash player:
Shockwave Flash
- File: libflashplayer.so
- Version:
- Shockwave Flash 10.2 d161
| MIME Type | Description | Suffixes | Enabled |
|---|---|---|---|
| application/x-shockwave-flash | Shockwave Flash | swf | Yes |
| application/futuresplash | FutureSplash Player | spl | Yes |
As usual, I've wrapped everything mentioned before into a script to easily install flash player square on Linux
If this version doesn't work out that well for you, you can still check my other tutorial on how to install native 64bit flash player on Linux
Happy browsing!
Magento create custom order statuses
This post is just a reminder for myself. It's taken from http://www.magentocommerce.com/boards/viewthread/9976/P30/ . The code below was tested and works just fine on magento 1.4.0.1
So to recapitulate, I did the following (citing the other guys, thanks to atlasit, ajayksh and rune00):
1) write a list of the additional statuses that you want
2) download and open the file Magento\app\code\core\Mage\Sales\etc\config.xml
(do not upload it again as soon as you’re done, you need to place it into a different folder, see below)3) find this code:
<pending translate="label"><label>Pending</label></pending>and after that add your own new custom status
<my_new_custom_status translate="label"><label>My New Custom Status</label></my_new_custom_status>4) Now find this code, a few lines below:
<states> <new translate="label"> <label>New</label> <statuses> <pending/> </statuses> </new>and under or above this block create a new block with your own custom status:
<states> <new translate="label"> <label>New</label> <statuses> <pending/> </statuses> </new> <my_new_custom_status translate="label"> <label>My New Custom Status</label> <statuses> <my_new_custom_status/> </statuses> </my_new_custom_status>repeat this (step 3 and 4) for each new custom status
5) So that you can change your status from the admin interface back and forth
from any current status, you need to edit again each of the status code block
as follows.change this
<new translate="label"> <label>New</label> <statuses> <pending/> </statuses> </new>to this
<new translate="label"> <label>New</label> <statuses> <my_new_custom_status/> <pending/> <processing/> <holded/> <complete/> <closed/> <canceled/> </statuses> <visible_on_front/> </new>you need to do this with all of the existing statuses and the new custom statuses that you’ve just created
so that these new statuses do not only become available and visible to the admin, but also to the customer
on his “my account” page (order history, current status), you need to make the new statues visible (thanks to rune00)
with the tag, as described above. 6) After you saved your changes, upload the new config.xml file to
/app/code/local/Mage/Sales/etc/ (you will need to create that folder structure)7)Create a file named Mage_Sales.xml with the following content (thanks to atlasit)
<?xml version="1.0"?> <config> <modules> <Mage_Sales> <active>true</active> <codePool>local</codePool> </Mage_Sales> </modules> </config>Upload it to /app/etc/modules/
that’s pretty much it.
If you got it running successfully as well, let us know so that it will help others as well.
CLI Disk Usage
Modern Linux systems have plenty of tools for both Gnome and Kde to analyze the disk space. But if you log into a server via SSH or similar, you're out of luck. You need a tool for Cli Disk Usage analytics. That tool is ncdu.
You can install it easy:
sudo apt-get install ncdu
Issuing ncdu inside the folder you want to check will open a cool ncurses interface, really easy to use
Converting disc images to another format on Linux
While this information is available all over the net, i find myself losing enough time now and again trying to figure out how to convert a disk image to iso or something useful for that matter. So i decided to put together a small tutorial on converting disk images to another format on Linux, so i can easily access it whenever i need it.
The most popular disk image formats i've had to deal with are: iso (which Ubuntu handles by default perfectly), CloneCD/IMG (used by CloneCD), CUE/BIN, MDF (created by Alcohol 120%), NRG (Nero images) and last but not least DMG (format used mainly by Apple).
Since Linux handles very well .iso files, the idea is to convert any of the image types listed into iso and then the job is easy. For all of the formats there are tools to do just that. You can install them as follows:
sudo apt-get install ccd2iso bchunk mdf2iso nrg2iso dmg2img
Example usage:
# ccd ccd2iso /path/to/example.img /path/to/example.iso # bin/cue bchunk /path/to/example.bin /path/to/example.cue /path/to/example.iso # mdf mdf2iso /path/to/example.mdf /path/to/example.iso # nrg nrg2iso /path/to/example.nrg /path/to/example.iso # dmg dmg2img filename.dmg
Some of those formats can be also mounted using the CLI:
# ccd/img sudo mount -o loop example.img /media/example # nrg sudo mount -o loop,offset=307200 /path/to/example.nrg /media/example # dmg dmg2img /path/to/example.dmg /path/to/example.img sudo modprobe hfsplus sudo mount -t hfsplus -o loop example.img /media/example
Convert wma to mp3 on Linux
Today i wanted to listed to some old tracks, which for some reason i had saved in .wma format. Added them to Rhythmbox and it complained about needing a plugin which it didn't find. I fired up Google and learned that i need to install some gstreamer codecs, but with my files it still didn't worked. That so, i decided to convert the wma files to mp3 using the Perl Audio Converter. Install was painless on Ubuntu 10.04:
sudo apt-get install pacpl
After install, go to the folder that contains your .wma files and run:
pacpl -t mp3 *.wma
Setting up Xdebug with Zend Server on Linux
Since our team work on different operating system, we switched for custom apache/php/mysql installs to Zend Server. Before everyone was using something different (the guys on windows were using XAMP, WAMP, on ubuntu i was using the packages in the repo and on the server we're using apache from cPanel) and applications were behaving a differently according to the default settings for all those platforms.
So we decided to install Zend Server CE as it has more or less the same settings over different platforms. I've had some bad experiences installing ZSCE on a system that already had apache installed via apt, but after a clear install of Karmic, ZF was running like a charm. The install process described in the online documentation works great.
After install is done, make sure to symlink php, pecl, pear and phpize so you can access them system wide:
sudo ln -s /usr/local/zend/bin/zendctl.sh /usr/sbin/zendctl sudo ln -s /usr/local/zend/bin/pear /usr/sbin/pear sudo ln -s /usr/local/zend/bin/pecl /usr/sbin/pecl sudo ln -s /usr/local/zend/bin/php /usr/sbin/php sudo ln -s /usr/local/zend/bin/phpize /usr/sbin/phpize
At this point you should be able to run php -i in terminal and the phpinfo will be displayed.
Next step is to install xdebug via pecl by running:
sudo pecl install xdebug
If all went well you should have the xdebug library located at /usr/local/zend/lib/php_extensions/xdebug.so . If you don't have it there, then something went wrong and you should NOT continue reading. This issue must be sorted first.
Next you need to comment out the 1st line of /usr/local/zend/etc/conf.d/debugger.ini so it looks like this:
#open editor gksu gedit /usr/local/zend/etc/conf.d/debugger.ini # this is how the 1st two lines should look afterwards ; register the extension to be loaded by Zend Extension Manager ;zend_extension_manager.dir.debugger=/usr/local/zend/lib/debugger
Xdebug needs to be loaded before Zend Extension Manager, that's why you need to add the following line just on top of the /usr/local/zend/etc/ext.d/extension_manager.ini
#open the editor gksu gedit /usr/local/zend/etc/ext.d/extension_manager.ini #add this line on 1st line: zend_extension=/usr/local/zend/lib/php_extensions/xdebug.so #save the file
Restart zend server by running:
sudo /etc/init.d/zend-server restart
You can check if xdebug is working like so:
php -i |grep xdebug
The output should be something similar to this:
xdebug xdebug support => enabled xdebug.auto_trace => Off => Off xdebug.collect_includes => On => On xdebug.collect_params => 0 => 0 xdebug.collect_return => Off => Off xdebug.collect_vars => Off => Off xdebug.default_enable => On => On xdebug.dump.COOKIE => no value => no value xdebug.dump.ENV => no value => no value xdebug.dump.FILES => no value => no value xdebug.dump.GET => no value => no value xdebug.dump.POST => no value => no value xdebug.dump.REQUEST => no value => no value xdebug.dump.SERVER => no value => no value xdebug.dump.SESSION => no value => no value xdebug.dump_globals => On => On xdebug.dump_once => On => On xdebug.dump_undefined => Off => Off xdebug.extended_info => On => On xdebug.idekey => mimir => no value xdebug.manual_url => http://www.php.net => http://www.php.net xdebug.max_nesting_level => 100 => 100 xdebug.profiler_aggregate => Off => Off xdebug.profiler_append => Off => Off xdebug.profiler_enable => Off => Off xdebug.profiler_enable_trigger => Off => Off xdebug.profiler_output_dir => /tmp => /tmp xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p xdebug.remote_autostart => Off => Off xdebug.remote_enable => Off => Off xdebug.remote_handler => dbgp => dbgp xdebug.remote_host => localhost => localhost xdebug.remote_log => no value => no value xdebug.remote_mode => req => req xdebug.remote_port => 9000 => 9000 xdebug.show_exception_trace => Off => Off xdebug.show_local_vars => Off => Off xdebug.show_mem_delta => Off => Off xdebug.trace_format => 0 => 0 xdebug.trace_options => 0 => 0 xdebug.trace_output_dir => /tmp => /tmp xdebug.trace_output_name => trace.%c => trace.%c xdebug.var_display_max_children => 128 => 128 xdebug.var_display_max_data => 512 => 512 xdebug.var_display_max_depth => 3 => 3
Note the xdebug support => enabled on line 2.
Hope that helps
Setup ZF using svn externals
After you create a project with zf tool, put it on SVN, you might want to include inside /library the ZF, but you want to have the bleeding edge all the time. You can include it as a svn external like this:
cd library/ svn propset svn:externals 'Zend http://framework.zend.com/svn/framework/standard/trunk/library/Zend/' .
Next time when you run svn up, your project will fetch the latest ZF from it's repo.