Skip to content

Instantly share code, notes, and snippets.

View mmenozzi's full-sized avatar
💻
CTO at Webgriffe®

Manuele Menozzi mmenozzi

💻
CTO at Webgriffe®
View GitHub Profile
@mmenozzi
mmenozzi / hipay-magento1-disable-notification.patch
Created June 15, 2020 10:31
HiPay Magento 1.x module notification patch
Index: app/design/adminhtml/default/default/layout/hipay.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- app/design/adminhtml/default/default/layout/hipay.xml (date 1591870391434)
+++ app/design/adminhtml/default/default/layout/hipay.xml (date 1591870391434)
@@ -57,10 +57,5 @@
<block type="hipay/adminhtml_card_edit" name="card.edit.container"></block>
</reference>
@mmenozzi
mmenozzi / upgrade_check.php
Last active June 11, 2020 08:49
Magento 1.x Upgrade Check Assistant Script
<?php
declare(strict_types=1);
/**
* Magento 1.x Upgrade Check Assistant Script
*
* To use this generate a rewrites JSON file with
*
* n98-magerun.phar dev:module:rewrite:list --format json > rewrites.json
*
Index: app/code/local/AW/Afptc/Model/Rule.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- app/code/local/AW/Afptc/Model/Rule.php (date 1568627129105)
+++ app/code/local/AW/Afptc/Model/Rule.php (date 1568627129105)
@@ -35,7 +35,7 @@
$this->setBuyXProductIds(array());
$allQuoteItems = $object->getQuote()->getAllItems();
diff --git a/app/code/local/AW/Rma/Model/Email/Template.php b/app/code/local/AW/Rma/Model/Email/Template.php
index 4b49765..2a21810 100644
--- a/app/code/local/AW/Rma/Model/Email/Template.php
+++ b/app/code/local/AW/Rma/Model/Email/Template.php
@@ -29,6 +29,10 @@
class AW_Rma_Model_Email_TemplateCommon extends AW_Customsmtp_Model_Email_Template
{
}
+} elseif (class_exists('Yireo_EmailOverride_Model_Email_Template')) {
+ class AW_Rma_Model_Email_TemplateCommon extends Yireo_EmailOverride_Model_Email_Template
@mmenozzi
mmenozzi / PATCH_SUPEE-389_EE_1.12.0.2_v2.patch
Created September 11, 2017 09:00
SUPEE-389: Every time the catalog URL is rendexed, a new custom rewrite is created (.patch format)
diff --git app/code/core/Mage/Catalog/Model/Url.php app/code/core/Mage/Catalog/Model/Url.php
index fa55fc5..a755b46 100644
--- app/code/core/Mage/Catalog/Model/Url.php
+++ app/code/core/Mage/Catalog/Model/Url.php
@@ -609,6 +609,23 @@ class Mage_Catalog_Model_Url
*/
public function getUnusedPath($storeId, $requestPath, $idPath)
{
+ $urlKey = '';
+ return $this->getUnusedPathByUrlkey($storeId, $requestPath, $idPath, $urlKey);
@mmenozzi
mmenozzi / undo_cancel.php
Last active January 15, 2016 11:18
Restore canceled order with Magento 1.x
<?php
// -------------------------------------------------
// Prevent script to be called via HTTP
// -------------------------------------------------
if (isset($_SERVER['REQUEST_METHOD'])) {
die('This script cannot be run from Browser. This is the shell script.');
}
// -------------------------------------------------
// Override useful ini values
@mmenozzi
mmenozzi / email_order_items.php
Last active January 14, 2016 10:56
Rendering Magento 1.x email order items
<?php
// -------------------------------------------------
// Override useful ini values
// -------------------------------------------------
set_time_limit(0); // avoid any time limit
ini_set('memory_limit', -1); // avoid any memory limit
// -------------------------------------------------
@mmenozzi
mmenozzi / docker-compose.yml
Last active January 12, 2016 07:51
MySQL from Docker or from the Host
php:
image: webgriffe/magento1-dev
volumes_from:
- unison
links:
- mysql
- memcached
- blackfire_agent:blackfire
environment:
HOST_IP: 192.168.99.1
@mmenozzi
mmenozzi / 0_reuse_code.js
Last active September 1, 2015 15:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mmenozzi
mmenozzi / SessionStartMock.md
Created July 20, 2015 09:37
Magento - Ecomdev_PHPUnit

When testing stuff with Ecomdev_PHPUnit the following error could occur:

Exception: Warning: session_start(): Cannot send session cookie - headers already sent by (output started at [...]/vendor/phpunit/phpunit/src/Util/Printer.php:172)  in [...]/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php on line 123

This error happens because somewhere in your tested code there is an itialization to a Magento's session singleton/model that casues a session_start which in turn needs to set the related cookie/session header. The error is thrown because the output has already started due to PHPUnit initial output.

The architecture of these Magento models sucks and there is no separation between domain session logic and PHP session_* functions but fortunately we can mock session calls through Ecomdev_PHPUnit.