Skip to content

Instantly share code, notes, and snippets.

@davirs
davirs / jv_clean_product_images.php
Created August 24, 2019 20:42 — forked from jeroenvermeulen/jv_clean_product_images.php
Script to clean up unused Magento images
#!/usr/bin/php
<?php
/**
* jv_clean_product_images.php
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
@davirs
davirs / customermagento.php
Created September 10, 2019 17:56 — forked from edrdesigner/customermagento.php
Get Logged In Customer’s Magento 1.9 details
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
// Load the customer's data
$customer = Mage::getSingleton('customer/session')->getCustomer();
$customer->getPrefix();
$customer->getName(); // Full Name
$customer->getFirstname(); // First Name
$customer->getMiddlename(); // Middle Name
<?php
$isMobile = Zend_Http_UserAgent_Mobile::match(
Mage::helper('core/http')->getHttpUserAgent(),
$_SERVER
);
@davirs
davirs / magento_varien_types.php
Created September 10, 2019 17:57 — forked from edrdesigner/magento_varien_types.php
Magento Varien Types
const TYPE_BOOLEAN = 'boolean';
const TYPE_SMALLINT = 'smallint';
const TYPE_INTEGER = 'integer';
const TYPE_BIGINT = 'bigint';
const TYPE_FLOAT = 'float';
const TYPE_NUMERIC = 'numeric';
const TYPE_DECIMAL = 'decimal';
const TYPE_DATE = 'date';
const TYPE_TIMESTAMP = 'timestamp'; // Capable to support date-time from 1970 + auto-triggers in some RDBMS
const TYPE_DATETIME = 'datetime'; // Capable to support long date-time before 1970
login url
<?php echo Mage::getUrl('customer/account/login'); ?>
logout url
<?php echo Mage::getUrl('customer/account/logout'); ?>
My Account url
<?php echo Mage::getUrl('customer/account'); ?>
Register url
*/5 * * * * php /home/bender/htdocs/cron.php -malways 1 > /dev/null
*/5 * * * * php /home/bender/htdocs/cron.php -mdefault 1 > /dev/null
* * * * * ! test -e /home/bender/htdocs_dev/www/maintenance.flag && /bin/bash /home/bender/htdocs_dev/www/scheduler_cron.sh --mode always
* * * * * ! test -e /home/bender/htdocs_dev/www/maintenance.flag && /bin/bash /home/bender/htdocs_dev/www/scheduler_cron.sh --mode default
@davirs
davirs / magento-address-autocomplete.js
Created September 13, 2019 13:59 — forked from rafaelpatro/magento-address-autocomplete.js
Magento Address Auto Fill based on Postcode
/**
* Address Auto Fill based on Postcode
*
* Author:
* Rafael Patro <[email protected]>
*
* Intallation:
* Add a CMS Static Block applying the entire script below.
* Add a Widget to pages with address forms.
*
@davirs
davirs / validacao+mascara.js
Created September 13, 2019 14:55 — forked from ricardodantas/validacao+mascara.js
Máscara e validação de RG, CNPJ, CPF, etc...
// JavaScript Document
//adiciona mascara de cnpj
function MascaraCNPJ(cnpj){
if(mascaraInteiro(cnpj)==false){
event.returnValue = false;
}
return formataCampo(cnpj, '00.000.000/0000-00', event);
}
//adiciona mascara de cep
@davirs
davirs / mage_get_widget.markdown
Created September 13, 2019 21:52 — forked from evgv/mage_get_widget.markdown
Magento. Get widget.

Get widget

You can create and use any existed widget type in your Magento site.

1. In static block or cms page

  {{widget type="cms/widget_page_link" template="cms/widget/link/link_block.phtml" page_id="2"}}

2. In layout

@davirs
davirs / remove_all_orders_magento.php
Created November 28, 2019 16:24 — forked from luizwbr/remove_all_orders_magento.php
Remove all orders Magento 1.9
<?php
require_once('app/Mage.php');
ini_set('display_errors', 1);
Mage::app('admin');
$orderIds = array(1,2,3,4);
$orders = Mage::getModel('sales/order')->getCollection()
->addFieldToFilter('entity_id', (array) $orderIds);
foreach ($orders as $o) {
//load order object - I know it's not ok to use load in a loop but it should be ok since it's a one time script
$order = Mage::getModel('sales/order')->load($o->getId());