Skip to content

Instantly share code, notes, and snippets.

@edannenberg
edannenberg / mavento_bash_completion
Created April 11, 2012 08:56
Bash completition for maven-magento-plugin.
# Programmable completion for the Maven mvn command under bash. Source
# this file (or on some systems add it to ~/.bash_completion and start a new
# shell) and bash's completion mechanism will know all about mvn's options!
#
# Copyright (C) 2009, Ludovic Claude <ludovic.claude@laposte.net>
# Base on git completion script, Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Distributed under the GNU General Public License, version 2.0.
# Customization: you can always edit this file (as root) and add or remove plugins and options in the lists defined below.
# If you have some interesting changes, please send patches to ludovic.claude@laposte.net
@edannenberg
edannenberg / magento_url_rewrite.patch
Last active August 11, 2022 17:27
Fixes the catalog url rewrite indexer in Magento 1.7.x-1.9.x See https://github.com/magento/bugathon_march_2013/issues/265 for details.Update: DexterDee in the ticket above noted that the previous patch had some side effects. This updated patch still feels like duct tape but at least it seems to be free of the mentioned side effects. It also fix…
diff -rupN mage_org/app/code/core/Mage/Catalog/Model/Url.php src_shop/app/code/core/Mage/Catalog/Model/Url.php
--- mage_org/app/code/core/Mage/Catalog/Model/Url.php 2013-11-19 00:48:25.679009391 +0100
+++ src_shop/app/code/core/Mage/Catalog/Model/Url.php 2013-11-19 00:49:24.188005601 +0100
@@ -643,13 +643,24 @@ class Mage_Catalog_Model_Url
$this->_rewrite = $rewrite;
return $requestPath;
}
+
+ // avoid unnecessary creation of new url_keys for duplicate url keys
+ $noSuffixPath = substr($requestPath, 0, -(strlen($suffix)));
<?php
/**
* Drop this into the shell directory in the Magento root and run with -h to see all options.
*/
require_once 'abstract.php';
/**
* Fix duplicate url keys for categories and products to work with the 1.8 alpha1 CE url key constraints.
@edannenberg
edannenberg / replicate-attribute-values.php
Last active December 17, 2015 08:08
Fixes possible borked filtered navigation after upgrading older Magento versions.
<?php
/**
* This will replicate attribute values of configurable products to all it's child products.
*
* Rationale: After upgrading Magento 1.4 to 1.7 we found that our filtered navigation was
* missing quite alot of products. Turns out somewhere after 1.4 Varien changed the filtered
* navigation to only use the attributes of child products, ignoring the attributes of
* their configurable products.
*
@edannenberg
edannenberg / magento_catinv_api.patch
Created October 17, 2013 11:41
Fixes catalogInventoryStockItemUpdate api call (V2) in Magento 1.8. Whats broken: The api method got refactored and now does not call $product->save() anymore. As a result the stock_id for new items is not set as the observer that takes care of that is hooked to the product_save_after event. Fix 1: Apply patch below. *OR* Fix 2: Update db schema…
--- mage_org/app/code/core/Mage/CatalogInventory/Model/Stock/Item/Api/V2.php 2013-10-17 12:24:37.773265017 +0200
+++ src_shop/app/code/core/Mage/CatalogInventory/Model/Stock/Item/Api/V2.php 2013-10-17 13:09:30.141351173 +0200
@@ -54,6 +54,7 @@
/** @var $stockItem Mage_CatalogInventory_Model_Stock_Item */
$stockItem = $product->getStockItem();
+ $stockItem->setStockId($stockItem->getStockId());
$stockData = array_replace($stockItem->getData(), (array)$data);
$stockItem->setData($stockData);
@edannenberg
edannenberg / magentrolol.md
Last active January 26, 2017 17:41
Magento 1.8.x tax calculation when using prices including tax.

We upgraded to 1.8 a couple of weeks ago, today i had to investigate this little gem:

trolol

The issue was reproducable by adding 3 of the above items to the cart, checking the db confirmed that the 2nd quote item already had the wrong tax value.

Digging down the culprit turned out to be in Mage_Tax_Model_Sales_Total_Quote_Subtotal and Mage_Tax_Model_Sales_Total_Quote_Tax:

collect() will call for each quote item:

@edannenberg
edannenberg / magento_getoptionid_collision.md
Last active October 12, 2016 23:03
Mage_Eav_Model_Entity_Attribute_Source_Abstract::getOptionId() value/label collision

Had to investigate a weird bug in our product data, turns out to be a Magento core "feature" that can cause option id/label collisions when using getOptionId() of Mage_Eav_Model_Entity_Attribute_Source_Abstract.

Truncated getAllOptions() array for a common size attribute:

Array
(
  [232] => Array
          (
 [value] =&gt; 104
diff -rupN src_org/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Subselect.php src_patched/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Subselect.php
--- src_org/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Subselect.php 2016-02-17 19:27:54.000000000 +0100
+++ src_patched/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Subselect.php 2017-05-04 16:36:44.349301447 +0200
@@ -114,7 +114,7 @@ class Mage_SalesRule_Model_Rule_Conditio
$attr = $this->getAttribute();
$total = 0;
foreach ($object->getQuote()->getAllVisibleItems() as $item) {
- if (parent::validate($item)) {
+ if (Mage_Rule_Model_Condition_Combine::validate($item)) {
$total += $item->getData($attr);