magento

Magento Cache

get all cache types
Mage::app()->getCacheInstance()->getTypes();

types
Mage::app()->getCacheInstance()->cleanType('config');
Mage::app()->getCacheInstance()->cleanType('layout');
Mage::app()->getCacheInstance()->cleanType('block_html');
Mage::app()->getCacheInstance()->cleanType('translate');
Mage::app()->getCacheInstance()->cleanType('collections');
Mage::app()->getCacheInstance()->cleanType('eav');
Mage::app()->getCacheInstance()->cleanType('config_api');

clear cache
Mage::app()->cleanCache();

Magento: Update footer copyright year

PHP script (/root/scripts/update_copyright_year.php)
<?php
$URL="https://raw.githubusercontent.com/panticz/magento/master/scripts/update_copyright_year.php";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

Cronjob (/etc/cron.d/newyear)
0 0 1 1 * root /root/scripts/update_copyright_year.php

Use in CMS block
{{config path='design/footer/copyright'}}

Dep: Update by SQL
update core_config_data
set value = CONCAT('© ', YEAR(CURDATE()), ' YOUR COMPANY INC.')
where path = 'design/footer/copyright';

Links
http://www.panticz.de/Magento-Cache

Magento: Add upload field to contact form

<?php
$URL="http://dl.panticz.de/magento/contact_attachment/form.phtml.diff";
echo "wget -q $URL -O - | patch -p2 \
/var/www/app/design/frontend/default/default/template/contacts/form.phtml";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

<?php
$URL="http://dl.panticz.de/magento/contact_attachment/IndexController.php.diff";
echo "wget -q $URL -O - | patch -p2 \
/var/www/app/code/core/Mage/Contacts/controllers/IndexController.php";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

<?php
$URL="http://dl.panticz.de/magento/contact_attachment/Mage_Contacts.csv.diff";
echo "wget -q $URL -O - | patch -p2 \
/var/www/app/locale/de_DE/Mage_Contacts.csv";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

Links
http://www.blog.magepsycho.com/adding-upload-field-in-contact-form-and-send-as-attachment/
http://www.magentocommerce.com/boards/viewthread/440759/

Magento: Create top category offer box

Create a top category offer box on Magento front page linked to a category and filled with one of selected products from a hidden category.

/var/www/app/design/frontend/default/default/template/catalog/product/top-category.phtml
<?php
$URL="http://www.panticz.de/sites/default/files/magento/home/top-category.phtml";
echo "Download: $URL";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

View featured products on top from product listing

<?php
$URL="http://www.panticz.de/sites/default/files/magento/featured/set_featured_product.php";
echo "

";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);
curl_close($ch);
echo "

";
?>
php -f set_featured_product.php sku1 sku2 sku3

clear magento cache

<?php
$URL="http://www.panticz.de/sites/default/files/magento/featured/update_featured_product.php";
echo "

";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);
curl_close($ch);
echo "

";
?>
php -f update_featured_product.php

Magento: Category list

./app/design/frontend/default/default/template/catalog/navigation/category_list.phtml
<?php
$URL="http://www.panticz.de/sites/default/files/magento/category/category_list.phtml";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

cms include php template
{{block type="catalog/navigation" name="catalog.leftnav" template="catalog/navigation/category_list.phtml" cat_id=2227}}

CSS
.category_list ul {
height: 120px;
margin-bottom: 15px;
}

.category_list li {
float: left;
width: 250px;
}

Magento: CMS extension

./app/design/frontend/default/default/template/ebook/view.php
<?php
$URL="http://www.panticz.de/sites/default/files/magento/cms/view.php";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

./app/add.php
<?php
$URL="http://www.panticz.de/sites/default/files/magento/cms/add.php";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

./app/del.php
<?php
$URL="http://www.panticz.de/sites/default/files/magento/cms/del.php";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

cms include php template
{{block type='core/template' template='ebook/view.php' filter='ebooks'}}

cms search
./app/design/frontend/default/default/template/cmssearch/result.phtml

Magento: Vertical Category Navigation (RicoNeitzel_VertNav)

Fix VertNav Category selection
<?php
$URL="http://www.panticz.de/sites/default/files/magento/VertNav/VertNav_getCurrentCategory.diff";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

remove duplicate base files
rm -r /var/www/app/design/frontend/base/default/template/vertnav/

Links
http://www.magentocommerce.com/magento-connect/vertical-navigation-with-css-classes.html - Download on Magento Connect
http://www.magentocommerce.com/boards/viewthread/244440/#t359105 - Bug report "Blocks HTML output cache error"