Skip to content

Instantly share code, notes, and snippets.

Alessandro Ronchi aleron75

Block or report user

Report or block aleron75

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@aleron75
aleron75 / privateaccess.php
Created Jun 19, 2015
POC that PHP doesn't allow calling private methods from inherited context
View privateaccess.php
<?php
class MyParent
{
public function includeFile()
{
include "privateaccess_included.php";
}
}
class MyChild extends MyParent
@aleron75
aleron75 / Data.php
Created Jun 16, 2015
Magento Compare Version
View Data.php
<?php
class Myvendor_Mymodule_Helper_Data extends Mage_Core_Helper_Data
{
/**
* Check whether current Magento version supports Transactions
*/
public function isTransactionSupported()
{
return version_compare(Mage::getVersion(), '1.4.0.1', '>');
}
@aleron75
aleron75 / load_media_gallery
Created May 19, 2015
Load Magento product media gallery
View load_media_gallery
@aleron75
aleron75 / log.php
Last active Aug 29, 2015
Magento log wrapper function
View log.php
public function log()
{
$args = func_get_args();
$formattedMsg = call_user_func_array('sprintf', $args);
Mage::log($formattedMsg, null, 'vendor_module.log', Mage::getStoreConfig('path/to/config'));
}
@aleron75
aleron75 / shell_delete_unused_images
Last active Apr 1, 2019
Delete no more used Product Images on Magento
View shell_delete_unused_images
<?php
require_once 'abstract.php';
class Mage_Shell_CheckImages extends Mage_Shell_Abstract
{
const CATALOG_PRODUCT = '/catalog/product';
const CACHE = '/cache/';
protected function _glob_recursive($pattern, $flags = 0)
@aleron75
aleron75 / collection_copy
Created Feb 20, 2015
Copy a Magento collection
View collection_copy
$originalCollection = Mage::getModel('catalog/product')
->getCollection();
$newCollection = Mage::getModel('catalog/product')
->getCollection();
$selectParts = array(
Varien_Db_Select::DISTINCT,
Varien_Db_Select::COLUMNS,
Varien_Db_Select::UNION,
@aleron75
aleron75 / beforesave
Created Dec 4, 2014
_beforeSave() on Magento Models
View beforesave
protected function _beforeSave()
{
$this->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate());
if ($this->isObjectNew() && null === $this->getCreatedAt()) {
$this->setCreatedAt(Mage::getSingleton('core/date')->gmtDate());
}
return parent::_beforeSave();
}
@aleron75
aleron75 / rt_admin
Last active Apr 22, 2016
Magento runtime for Administrator
View rt_admin
<?php
// Prevent this script to be called via HTTP
if (isset($_SERVER['REQUEST_METHOD']))
{
die('Permission denied.');
}
// Avoid any time limit
set_time_limit(0);
@aleron75
aleron75 / rt_customer
Last active Apr 22, 2016
Magento runtime for Customer
View rt_customer
<?php
// Prevent this script to be called via HTTP
if (isset($_SERVER['REQUEST_METHOD']))
{
die('Permission denied.');
}
// Avoid any time limit
set_time_limit(0);
@aleron75
aleron75 / Create.php
Last active Aug 29, 2015
Mage_Adminhtml_Model_Sales_Order_Create->initFromOrder()
View Create.php
// This snippet from line 267 of class Mage_Adminhtml_Model_Sales_Order_Create of Magento CE 1.8.x or EE 1.13.x
public function initFromOrder(Mage_Sales_Model_Order $order)
{
// ...
$this->getQuote()->getPayment()->addData($order->getPayment()->getData()); // line 329
// ...
$this->getQuote()->save();
return $this;
}
You can’t perform that action at this time.