Skip to content

Instantly share code, notes, and snippets.

View edrdesigner's full-sized avatar

Eduardo Reichert edrdesigner

View GitHub Profile
<?php
$isMobile = Zend_Http_UserAgent_Mobile::match(
Mage::helper('core/http')->getHttpUserAgent(),
$_SERVER
);
// @overright = app/code/core/Mage/Core/Controller/Response/Http.php
public function sendHeaders()
{
if (!$this->canSendHeaders()) {
Mage::log('HEADERS ALREADY SENT: '.mageDebugBacktrace(true, true, true));
return $this;
}
if (in_array(substr(php_sapi_name(), 0, 3), array('cgi', 'fpm')))
{
@edrdesigner
edrdesigner / Observer.php
Created August 2, 2017 14:29 — forked from mystix/Observer.php
Delete abandoned Magento shopping carts -- see http://www.magentocommerce.com/boards/viewthread/53981/P15/
<?php
/*
To make the cleaning expired carts automatic, override cleanExpiredQuotes with the following
version which will also take care of the old active carts: app/code/core/Mage/Sales/Model/Observer.php
*/
public function cleanExpiredQuotes($schedule)
{
// extending limit
/**
* For mobile banner.
*/
$.smartbanner({
title: 'TITULO DO SITE',
author: 'DESCRICAO OU AUTHOR',
price: 'GRÁTIS',
appStoreLanguage: 'pt-br',
inAppStore: 'Disponível na App Store',
inGooglePlay: 'Disponível no Google Play',
/**
* Add funcionality to change the focus using tab and shiftkey
*/
function matrixTabIndex() {
var tabKey = 9;
$('#product-matrix-std .owl-item').each(function(){
$(this).find('INPUT[type=hidden]').attr('tabindex', '-1');
@edrdesigner
edrdesigner / magento_varien_types.php
Created July 7, 2017 18:37
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
@edrdesigner
edrdesigner / customermagento.php
Created July 5, 2017 11:35
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
SELECT DISTINCT(p.ID), p.post_title, p.post_content FROM `wp_posts` p
LEFT JOIN wp_posts im ON p.ID = im.post_parent AND im.post_type = "attachment"
WHERE p.post_status ='publish'
AND p.post_type = "post"
AND im.ID IS NULL
AND p.post_content NOT REGEXP 'src=".*"'
<?php
$date_plus_60_days = new DateTime("30-06-2017");
$date_plus_60_days->modify("+1 days");
$date_plus_60_days->modify("+3 days");
//echo $date_plus_60_days->format("D");
$d_leadtime = 3;
$date = "30/06/2014";

Magento Snippets

Set all categories to is_anchor 1

Find attribute_id

SELECT * FROM eav_attribute where attribute_code = 'is_anchor'

Update all of them with anchor_id from above (usually is ID 51)

UPDATE `catalog_category_entity_int` set value = 1 where attribute_id = 51