Magento can't reindex data through admin
Posted Thu, 01/19/2012 - 3:15pm
If you're trying to reindex data under "Index Management" but can't, do the following to fix the problem...
in SSH.
rm -rf var/locks/*Now try again, and you should be successful
If that doesn't work, also make sure the var/locks dir is writable.
chmod -R 777 var/locksHow to place drupal blocks anywhere in content.
Posted Fri, 10/21/2011 - 8:43pm
If you're looking to place a block anywhere inside your content, simply do the following:
go to /admin/build/block
select the block you want to insert into your content to get the proper block references...
e.g. I created a custom views block called "latest_news" which, if you click it's url looks like:
/admin/build/block/configure/views/latest_news-block
so basically, you'll use "views" at the beginning of the function reference and "latest_news-block" at the end:
Drupal 7 method
Menu block
How to install safe-rm.
Posted Thu, 10/20/2011 - 12:07pm
So, you're worried about accidentally wiping out your entire system or important directory by doing something like rm -rf / or rm -rf *
with safe-rm , it won't allow you to do that, you'll get something like:
$ rm -rf /
Skipping /Here's how to install:
cd /usr/local/src
# get latest version here: http://www.safe-rm.org.nz/
wget http://launchpad.net/safe-rm/trunk/0.8/+download/safe-rm-0.8.tar.gz
tar xvfz safe-rm-0.8.tar.gz
cd safe-rm-0.8
# find out your $PATH;
echo $PATH # most systems should include /usr/local/bin, if not then select any other listed
cp /bin/rm /usr/local/bin/rm
mv /bin/rm /bin/rm-01
cp safe-rm /bin/rm
vi /etc/safe-rm.confhttpd causing high CPU load in CentOS / DirectAdmin
Posted Thu, 10/06/2011 - 3:52am
If you did TOP in ssh, and noticed httpd process has a high cpu load, and has been running for a long time (e.g. over 5 minutes) then you might try lowering your MaxRequestsPerChild.
vi /etc/httpd/conf/extra/httpd-mpm.confNow change your MaxRequestsPerChild from 1000 to 20...
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 10
MaxSpareServers 20
ServerLimit 812
MaxClients 812
MaxRequestsPerChild 20
</IfModule>service httpd restartDisplay file attachment information in Drupal
Posted Thu, 09/22/2011 - 10:43pm
Here's a code snippet for Drupal to add filefield data to any node or block.
Basically this is used to pull information from a CCK filefield.
<?php
function downloads_files($nid) {
$node = node_load(array('nid'=>$nid));
$output_title = $node->title;
$output_file_url = $node->field_pdf_file[0]['filepath'];
$file_size = $node->field_pdf_file[0]['filesize'];
$output_file_size = format_size($file_size);
return '<a href="/'.$output_file_url.'">'.$output_title.' ('.$output_file_size.') <br /> <strong class="more">Download</strong></a>';
}
?>Magento upgrade to 1.5.x or 1.6.x
Posted Sat, 07/09/2011 - 3:26am
As many magento users will know, Magento is no fun to work with-- mainly due to poor community support (the developers help paying customers; i.e. Magento Enterprise ... Only payed support there... Great for business but bad for the average or beginning user...)
Anyhow...
So here's how we do it.
MAKE A BACKUP!
You can skip this step all together, however, please make a backup of everything prior to beginning the upgrade.
Create a test environment somewhere on your server (preferably away from your production installation)
How to get 3TB HDD to work with NVIDIA motherboards
Posted Sat, 05/14/2011 - 4:37pm
If you recently tried installing a 3TB Hard Drive you'll notice that only about 1/3 of the drive is recognized by Windows. The fix is quite simple:
1. Download NVIDIA nForce Drivers 15.58 or later
2. Install the NVIDIA NFORCE 15.58 drivers and reboot your system after the install is done.
3. You're done. Your PC should be able to see the entire 3TB drive (it should be around 2.72TB)
How to fix Traktor not keeping play count or mp3 comment changes
Posted Thu, 03/24/2011 - 4:02pm
So... Here I was playing sets on my new Traktor S4 on my 2010 iMac, and noticed that Traktor was acting weird--comments were getting erased, ratings were disappearing, play counts weren't being kept. In other words,Traktor's explorer worked on some files and not others.
I tried changing file permissions, reinstalling Traktor, etc... nothing solved the problem... Doing research didn't show me any concrete solutions (e.g. change the play count settings; this didn't work).
Then it occurred to me, I haven't defragmented my Windows PC in over 2 months. And a few weeks before, I had my windows PC sync all my mp3 files to my iMac.
So long story short, the mp3 files were messed up ("garbage at the end of file")...
The solution
How to uninstall multipletablerates from magento
Posted Tue, 12/14/2010 - 11:01am
Multiple Table Rates (aka multipletablerates) was a very popular extension in the magento 1.3 and earlier days... However, after several magento versions this extension basically became completely unstable/buggy (this is normal as it only lists magento 1.1 compatability)... Even so, it still worked on magento 1.3 with a few minor bugs... Then later down the road other extensions came up (mostly paid) that provided similar functionality, plus some, and minus the bugs...
Magento Catalog Price Rules bugs
Posted Mon, 11/15/2010 - 11:33am
Magento's "Catalog Price Rules" was always a buggy experience, ever since magento 1.3... I don't know what's going with the development, but it's still buggy up to 1.4.1 ...
So here are a couple of fixes I found.
Magento 1.4.0.1:
source: http://www.magentocommerce.com/boards/viewthread/194930/#t245120
1. Open up Observer.php in /app/code/core/Mage/CatalogRule/Model/
2. Find the dailyCatalogUpdate() method
3. At the end of the method, before “return $this;”, add:
$this->applyAllRules( $this );
4. (Not sure if this step is necessary) Open up /app/code/core/Mage/CatalogRule/etc/config.xml
5. Find the crontab > jobs > catalogrule_apply_all area
6. Change
<cron_expr>0 1 * * *</cron_expr>
Repair and Optimize MySQL databases in SSH
Posted Tue, 10/05/2010 - 12:38pm
SSH repair and optimize all MySQL databases:
/usr/bin/mysqlcheck --repair --all-databases --password/usr/bin/mysqlcheck --optimize --all-databases --password=xxxxxxImport/export MySQL in SSH
Posted Mon, 10/04/2010 - 11:30am
Export:
mysqldump -u USERNAME -p DATABASENAME > backupfile.sqlImport :
mysql -u USERNAME -p DATABASENAME < backupfile.sqlConnect:
mysql -uusername -p DATABASENAMEDisable scroll wheel zoom in Firefox
Posted Fri, 10/01/2010 - 6:24pm
This is probably an annoyance for all those that use keyboard CTRL commands (like, CTRL-C and CTRL-V) and accidentally keep hitting CTRL + mouse scroll wheel, which zooms in and out, or enlarges and decreases text size in your browser...
Here's how to disable that in firefox...
Firefox:
In your address bar, type in
about:configsearch for
mousewheel.withcontrolkey.actionChange the value to "0"
Restart your browser, and you're all set.
Google Chrome
Nothing available at the time of this writing...
Magento default sort order
Posted Fri, 08/20/2010 - 1:36pm
In order to specify the default sort order of the product listing open up your 'catalog.xml' (this is tested in magento 1.4):
desc
To order products by a specific order, e.g. to order products by the order specified under category listing:
set in your admin: yoursite.com/admin/system_config/edit/section/catalog/
Product listing sort by: Best ValueAnd for those wondering where 'category products' is... it's located here: /admin/admin/catalog_category/ (under "Category Products" tab, when you click on any category)
How to add free shipping notice on product listing and product view in Magento
Posted Tue, 04/20/2010 - 3:30pm
NOTE: This tutorial assumes you're using an extension that uses the "special_shipping_group" attribute... But you can also use this tutorial to output any attribute you'd like into the product view and product listing.
Ok... Say you're using the "special_shipping_group" attribute, to specify which products should receive free shipping.
You would, for example, add an attribute called: FREE SHIPPING
Make sure you also set this visible under product listing, and product view, or else it won't display.
Magento Featured Products Listing on Home Page
Posted Thu, 03/25/2010 - 3:38pm
There are a few articles and extensions I've come across showing how to add "Featured Products" on the home page of Magento. The problem is that none that I have read, seem to fully tackle the issue of being compatible with Magento 1.4.x (Magento 1.4.0.1 at the time of this writing) AND fully using Magento's features while being fairly easy to implement (i.e. without adding complicated, unnecessary,redundant or outdated code)
Magento 1.4 toolbar error (How to properly upgrade to Magento 1.4)
Posted Thu, 03/04/2010 - 12:55pm
In case you upgraded to magento 1.4, and noticed that your category listings that require pagination (page 1, 2, 3) no longer show, here's the fix...
1. copy the new 1.4 toolbar.phtml from
app/design/frontend/base/default/template/catalog/product/list/toolbar.phtml
and paste it into your custom theme
app/design/frontend/*/YOURTHEME/template/catalog/product/list/toolbar.phtml
(note: make sure you put this into your currently used theme directory. If you installed a theme via Admin-->System-->Design then get the name of the theme from there)
2. edit your app/design/frontend/*/YOURTHEME/layout/catalog.xml
Find:
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">If you can't connect to magento admin after upgrade
Posted Wed, 03/03/2010 - 12:42pm
In case you upgraded to magento 1.4 and can't connect to admin section (you get an error)...
Then do the following:
- SSH into your magento install directory.
- remove all files from ./app/code/core/Zend/Cache/
rm -rf app/code/core/Zend/Cache/*How to remove Yoast MetaRobots from Magento
Posted Wed, 03/03/2010 - 11:26am
In case you want to upgrade to magento 1.4, and have Yoast MetaRobots installed, you'll have to uninstall it first, since it's not compatible with 1.4.
Here's how:
1. uninstall it from magento connect
2. Remove the config xml file from /app/etc/modules/Yoast_Metarobots.xml
3. Remove the module files and directories from /app/code/community/yoast/Metarobots/
4.Clear your cache
SSH into your root magento directory and:
rm -rf var/cache/*5. run this SQL query (easily done in phpMyAdmin)
DELETE FROM `eav_attribute` WHERE `eav_attribute`.`attribute_code` = 'meta_robots';
DELETE FROM `core_resource` WHERE CODE = 'metarobots_setup'; You should be good to go after this...
Magento 1.4 product-name quotes are converted to html and then escaped
Posted Tue, 02/23/2010 - 11:43am
After upgrading from magento 1.3 to 1.4, if your product headings used quotes " " or ampersands & , then magento may convert these into HTML and then escape that HTML counterparts hence showing e.g.:
"Thermo Balance" Tub & Shower Valve Rough In Valve
like:
"Thermo Balance" Tub & Shower Valve Rough In Valve
The fix is to go into "view.phtml" and change:
<h1 class="product-name">
<?php echo $_helper->productAttribute($_product, $this->htmlEscape($_product->getName()), 'name') ?>
</h1>to
<h1 class="product-name">
<?php echo $this->htmlEscape($_product->getName())?>
</h1>How to remove <br /> added by magento.
Posted Tue, 02/16/2010 - 10:10am
In case you're wondering why your product description is all spaced out, then that's because magento is adding automatic line breaks into the content description area...
To get rid of it... look for
nl2brspecifically in description.phtml you'll see
<div class="std">
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), nl2br($this->getProduct()->getDescription()), 'description') ?>
</div>it should look like this after you take the nl2br out:
<div class="std">
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), ($this->getProduct()->getDescription()), 'description') ?>
</div>Drupal: How to create a View that shows results only from the current node
Posted Sat, 02/06/2010 - 1:27am
Let's say you want to create a Views block that shows on a bunch of different pages/nodes that have multiple (imagefield) images per page, and you want the block to dynamically display ONLY the images from the particular node you're on--and not display images from other nodes.
This is how you would do it:
1. Create your view as you normally would.
2. Add "Node: Nid" under "Arguments".
3. Select "Provide Default Argument" under "Action to take if argument is not present:"
4. Select "Node ID from URL" under "Default argument type:"
5. Leave everything else as is...
6. Hit "Update" and then "Save"... and you're done.
How to disable PHP 5.3 Deprecated errors
Posted Fri, 02/05/2010 - 12:15am
If you installed PHP 5.3, then you may have noticed many deprecated errors from older web apps and even current ones--like some drupal modules.
NOTICE: this is not a true fix, you could be ignoring critical errors by doing the following... but most likely you should be fine... though make sure you do not log errors, or your log files will quickly grow to an unmanageable size.
anyhow...
via php.ini :
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
; change this to Off if you still get errors.
display_errors = On
log_errors = Offalso, some sites may be using their own .htaccess or error_reporting... therefore you may need to go to affected ones and modify the .htaccess file and insert the following to disable PHP 5.3 ... I had to do this for really old web apps.
php_flag display_errors off
php_flag log_errors offafter your done... as always, restart apache...
service httpd restartHow to search and replace text in multiple files in linux
Posted Thu, 02/04/2010 - 9:57pm
Here's how to replace a string of text in multiple files under a specific directory and all it's sub directories.
cd /to/directory/containing/files
find . -name '*.php' | xargs perl -pi -e "s/OLDSTRING/'NEWSTRING'/g;"Real world example:
Let's say we want to replace the following in every .php file:
'profile', 'load_profile'with new string
'profile_load_profile'Hence, we do the following...
cd /home
find ./ -name '*.php' | xargs perl -pi -e "s/'profile', 'load_profile'/'profile_load_profile'/g;"How to install mod_expires using custombuild
Posted Thu, 02/04/2010 - 7:15pm
cd /usr/local/directadmin/custombuild
mkdir -p custom/ap2
cp configure/ap2/configure.apache custom/ap2/configure.apache
vi custom/ap2/configure.apacheadd: --enable-expires
so it looks like this:
#!/bin/sh
"./configure" \
"--prefix=/etc/httpd" \
"--exec-prefix=/etc/httpd" \
"--bindir=/usr/bin" \
"--sbindir=/usr/sbin" \
"--sysconfdir=/etc/httpd/conf" \
"--enable-so" \
"--enable-dav" \
"--enable-dav-fs" \
"--enable-dav-lock" \
"--enable-suexec" \
"--enable-deflate" \
"--enable-unique-id" \
"--with-suexec-caller=apache" \
"--with-suexec-docroot=/" \
"--with-suexec-gidmin=100" \
"--with-suexec-logfile=/var/log/httpd/suexec_log" \
"--with-suexec-uidmin=100" \
"--with-suexec-userdir=public_html" \
"--with-suexec-bin=/usr/sbin/suexec" \
"--with-included-apr" \
"--with-pcre=/usr/local" \
"--includedir=/usr/include/apache" \
"--libexecdir=/usr/lib/apache" \
"--datadir=/var/www" \
"--localstatedir=/var" \
"--enable-logio" \
"--enable-ssl" \
"--enable-rewrite" \
"--enable-proxy" \
"--with-ssl=/usr" \
"--enable-headers" \
"--enable-expires"./build clean
./build apache
service httpd restartyou may need to recompile php after this
./build phpCannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable.
Posted Wed, 01/27/2010 - 1:10am
if you try running the following:
phpizeand get this error
$PHP_PREFIX/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
Then it's because you don't have autoconf installed.
To fix this error, do the following:
yum install autoconfor you can install from source (if you want to use the latest version)
cd /usr/local/src/
/* find latest version of m4 here: http://ftp.gnu.org/gnu/m4/ */
How to search for text inside files in Linux
Posted Mon, 01/25/2010 - 1:57pm
To search for a text pattern in files in linux, do the following:
find / -type f -print0 | xargs -0 grep -i 'your pattern'
How to remove Paypal Quick Checkout button from Magento when using Paypal.
Posted Thu, 12/03/2009 - 2:09pm
If you disable "guest checkout" in magento -- and are using PayPal -- guest check is still possible via Paypal button--it will show below the "Proceed to Checkout" button.
In order to completely remove the possibility of Guest checkout, you'll need to alter the following:
app/design/frondend/default/YOURTEMPLATE/template/paypal/link.phtml- copy link.phtml to link-01.phtml or whatever
- open/edit link.phtml and delete (or comment out) everything.
How to add custom javascript into the drupal webform module <form> <submit>
Posted Tue, 12/01/2009 - 2:43pm
Recently, one of our clients asked to have custom tracking code implemented into their form submissions.
Since the client's site is built on Drupal, all forms are dynamically generated using the Webform module.
Their marketing company instructed us to add an 'onclick' code to
<input type="submit" class="form-submit" value="Receive Coupons" id="edit-submit" name="op" onclick=tracking("track_submit_quote") />However, since the Webform module creates all forms dynamically, there was no convenient way of hard coding the code into the form... i.e. there was no way for this to be done via webform admin.
phpMyAdmin database export "Save as file" template
Posted Wed, 11/25/2009 - 11:18am
Whenever you do a database backup using phpMyAdmin, you are presented with a default file name structure for saves, usually like so:
__DB__
which basically gives you the name of the database you just backed up. Which is ok, however, most people would also like the date and time stamp included as well...
So...
This is how it's done... replace the above with :
__DB__-%F-%Tor for newer version of phpMyAdmin
@DATABASE@-%F-%T__DB__ = name of database Example: my_database
%F = Same as "%Y-%m-%d" (year-month-day) Example: 2009-11-25
%T = time stamp . (24 hour format, hour_minute_second) Example: 11_07_31
which will save a file with the naming structure similar to:
my_database-2009-11-25-11_07_31.sql
You can easily use other date/time structure, to suit your personal preference.