Skip to content

Instantly share code, notes, and snippets.

@lykciv
lykciv / magento_remove_images_from_products.php
Last active December 31, 2015 05:29
Magento: remove images based on specific file-name from active simple products. Also excludes specific category.
<?php
$products = Mage::getModel('catalog/product')->getCollection()
->addFieldToFilter('type_id','simple')
->addFieldToFilter('status',1);
$counter = 0;
foreach ($products as $product)
{
if ($counter < 100) {
@lykciv
lykciv / magento_dates.php
Last active December 25, 2015 01:59
Magento dates
<?php
$now = Mage::getModel('core/date')->date();
// output: 2013-10-09 12:00:27
$date = new DateTime();
$date = $date->modify('-1 day');
$yesterday = Mage::getModel('core/date')->date(null, $date->getTimestamp());
// output: 2013-10-08 12:01:51
# find a file/folder which contains certain string
find . -iname '*filename*'
# count all files in current directory
# -type f = files
# wc -l = word count lines
find . -type f | wc -l
# diff commands
# write diff results to file
@lykciv
lykciv / crontab.txt
Last active December 22, 2015 05:29
Activate crontab for Magento
# crontab -e
*/5 * * * * /bin/sh /var/www/src/cron.sh
# system logging for cronjobs
# tail -f /var/log/syslog | grep 'CRON'
@lykciv
lykciv / magento_product_attribute.php
Created September 2, 2013 16:02
Add product attribute in Magento with mysql install/upgrade script
$setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'custom_product_attribute', array(
'group' => 'General',
'input' => 'boolean',
'type' => 'int',
'label' => 'Attribute Label',
'source' => 'eav/entity_attribute_source_boolean',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
@lykciv
lykciv / magento_urls
Last active February 13, 2023 13:10
Useful magento links
// error templates
// Code exception
http://website.com/errors/report.php?id=123456789
// 503 error
http://website.com/errors/503.php
// 404 error
http://website.com/errors/404.php
// Ogone template
http://website.com/ops/payment/paypage/
@lykciv
lykciv / magento_debug_file.php
Last active December 21, 2015 21:18
Magento debug file: load a specific product and dump data Save this in a file in your magento root folder.
<?php
require 'app/Mage.php';
Mage::init('admin');
$product = Mage::getModel('catalog/product')->load('123');
var_dump($product->getData());