Skip to content

Instantly share code, notes, and snippets.

View milansimek's full-sized avatar

Milan Simek milansimek

View GitHub Profile
@lvampa
lvampa / magento2-add-file-to-head.txt
Created May 16, 2016 23:07
Magento 2 - Two ways to add files to page head
Step-by-step guide
Create the files
Namespace/Module/view/frontend/web/hello.js
Namespace/Module/view/frontend/web/test.js
In the Layout
NOTE - notice how the filename is the layout handle we want to use.
Namespace/Module/view/frontend/view/layout/default_head_blocks.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
@joshcarlson
joshcarlson / magento-add-to-cart-from-query-string.php
Created April 11, 2015 15:55
Magento add to cart from url, useful for email promos or add to cart from offsite links
<?php
/**
* add to cart from url, useful for email promos
* based on http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/catalog/adding_a_product_to_the_cart_via_querystring
* which no longer works because of session validation of form_key
* usage: link to add.php?product=[id]&qty=[qty]
*/
require 'app/Mage.php';
Mage::app();
@rakeshtembhurne
rakeshtembhurne / import_export_gz.sql
Created July 15, 2013 08:40
MySQL: Import and export in gzip form
// Export database in gzip form
mysqldump -u user -p database | gzip > database.sql.gz
// Import database from gzip form
gunzip < database.sql.gz | mysql -u user -p database
@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)));