Posts Tagged ‘code’
Magento Invoice and Shipping (Despatch) PDF files are delivered with a reasonable layout, already suited toA4 printing, but benefit from some layout improvements, increasing font sizes, and lightening the greyscale boxes in the interests of readability.
Take a copy of the relevant core files and place them in:
/app/code/local/Mage/Sales/Model/Order/Pdf
The relevant files are Invoice.php & Shipment.php, but Abstract.php contains functions common to both, and the subdirectory Items contains formatting for the line items of each document type.
The following snippet can be used to format database values as currency values:
$formattedPrice = Mage::helper('core')->currency($Price,true,false);
The upgrade to 1.5 has a number of “gotchas” so while I am debugging the process on the test / staging instance, here are a few notes.
Basic process
Empty some or all of the log tables as they are potentially huge and are not needed:
TRUNCATE `log_customer`;
TRUNCATE `log_quote`;
TRUNCATE `log_summary`;
TRUNCATE `log_url`;
TRUNCATE `log_url_info`;
TRUNCATE `log_visitor`;
TRUNCATE `log_visitor_info`;
TRUNCATE `log_visitor_online`;
Backup the 1.3 instance using Magento’s built in backup.
Edit the resulting .sql file and uncomment the FOREIGN_KEY controls at the top and bottom of the file:
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
If the domain or subdomain is changing, do a search & replace e.g. replace www.myshop.com with test5.myshop.com
Create the new database instance, and execute the SQL from the previous step. Make sure it doesn’t time out, last table created is normally “wishlist_item”
Yoast Metarobots breaks product maintenance in Magento 1.4+, so remove relevant fields:
DELETE FROM `core_resource` WHERE `core_resource`.`code` = 'metarobots_setup';
DELETE FROM `eav_attribute` WHERE `eav_attribute`.`attribute_code` = 'meta_robots';
UPDATE eav_entity_type SET additional_attribute_table='catalog/eav_attribute',entity_attribute_collection='catalog/product_attribute_collection' WHERE entity_type_id=4;
Now FTP the Magento downloader.php onto the target site, check file permissions and execute it with http://test5.myshop.com/downloader.php
Follow the setup process including specifying the correct database name, user and password.
Use the same encryption key from the original site – find it in /app/etc/local.xml
If there are problems with the setup not accepting the admin user / password combination, simply re-run the installer by pointing your web browser at http://test5.myshop.com
Remember that the original admin user already exists in the database export, so create a temporary one and delete it later.
Fixing problems
Can’t access the admin site, gives 404 error
The database import will have incorrectly sequenced the sites, so run the following:
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
UPDATE core_website SET website_id="0" WHERE core_website.code="admin" LIMIT 1;
UPDATE core_store SET store_id="0" WHERE core_store.code="admin" LIMIT 1;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
Admin site is “white” i.e. CSS not working and plain HTML is displayed
Delete contents of /var/cache/
“There are no products matching the selection” when browsing front end
Wrong customer group ID for users that are no logged in. Execute the following SQL:
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
UPDATE `customer_group` SET `customer_group_id` = 0 WHERE `customer_group_code` LIKE 'NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
No product images
Check correct permissions and then copy the images directory structure from the source site eg:
cp /httpdocs/media/catalog/* /subdomains/test5/httpdocs/media/catalog/
Now login to admin site and run a re-index on everything, and update all of the caches.
Error File does not exist: … media/catalog/product/no_selection
Review the System Configuration and under Catalogue / Catalogue / Product Image Placeholders and add the missing placeholders. Add back in the watermarks too in General / Design / Product Image Watermarks.
This page has bidirectional binary – ASCII conversion. This is useful if you are following @cjsupercomputer.
A quick how-to if you want to copy or move Magento to another database instance, e.g. to create a test site, or move test to live.
(1) Backup Magento using the built in backup tool. Download and uncompress the resulting SQL script. If changing the server or domain, search and replace “old.mysite.com” with “new.yoursite.com” Execute it to populate the new database instance.
(2) Copy all Magento files with the exception of the contents of the var/ directory.
(3) Edit app/etc/local.xml on the target instance and change the database, user and password, but not the encryption key. Also edit downloader/pearlib/pear.ini to correct the absolute paths it contains; no reason why these shouldn’t be relative to the Magento root directory, e.g. “./downloader/pearlib”.
(4) Execute the following SQL to prevent those nasty “Integrity constraint violation: 1062 Duplicate entry” errors from the log files when adding to the basket:
TRUNCATE `log_customer` ;
TRUNCATE `log_quote` ;
TRUNCATE `log_summary` ;
TRUNCATE `log_url` ;
TRUNCATE `log_url_info` ;
TRUNCATE `log_visitor` ;
TRUNCATE `log_visitor_info` ;
TRUNCATE `log_visitor_online` ;
Now tidy up permissions:
chmod o+w var var/.htaccess app/etc
chmod -R o+w media
That should be it.
If you are running Skype v3 or later, there is a registry change (provided by Skype for Universities etc.) that reportedly prevents your PC becoming a supernode. I say reportedly, because whilst I have been a guinea pig for the last week I haven’t noticed being a supernode, but of course Skype may not have tried. If you aren’t running the latest version of Skype yet you should probably upgrade (Help, Check for updates), because later versions allow you to edit previous messages, and voice quality is improved.
If you think that being a supernode may cause you problems, try editing the registry as shown in the code below. (WordPress security doesn’t allow this file to be uploaded). You will need to reboot your PC for it to take effect.
This is the edit:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Skype]
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Skype\Phone]
"DisableSupernode"=dword:00000001
Here is some DOS / NT CMD Script code to sleep for n seconds:
@echo off
echo Sleeping for 5 seconds
call :sleep 5
echo Done
goto :EOF
:sleep
:: This subroutine sleeps for n seconds
ping -n %1 127.0.0.1 > NUL 2>&1
goto :EOF
OK, so Epson’s support proved to be useless – “isn’t there a DIP switch on the back” and “we don’t do programming here” seemed to be the best they can offer.
Inspiration led me to lookup the ESC/POS sequences for cursor display – not DC2 & DC4 as previously though, they use the ASCII US (31 decimal) commands:
USC 3167n select/cancel cursor display
n=0,1 (48,49 decimal)
So, back to uedit and try to work out what difference 0, 1, (48 & 49 decimal)Â make to the thing…
15/02/2007: answer: None at all!
Aparently UTW suffers from an expensive query – this site has a fix:
http://ocaoimh.ie/2006/09/27/simple-utw-performance-boost/
From xlDynamic.com
File path, file and worksheet name:
=CELL("filename",A1)
File path only:
=LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1),1)-1)
File name only:
=MID(CELL("filename",A1),FIND("[",CELL("filename",A1),1)+1,
FIND("]",CELL("filename",A1),1)-FIND("[",CELL("filename",A1),1)-1)
The sheet name:
=MID(CELL("Filename",A1),FIND("]",CELL("Filename",A1))+1,255)
Restriction: this technique only works for workbooks that have been saved at least once.
I really must get around to implementing these plug-ins to stop clutter in the WordPress category and page lists.
See also here.
Consider the following JavaScript:
// Toggle Show/Hide
function toggle(name) {
if (document.getElementById(name).style.display == "block") {
document.getElementById(name).style.display = "none";
} else {
document.getElementById(name).style.display = "block";
}
}