Skip to content

Instantly share code, notes, and snippets.

@andrew-smart
andrew-smart / patch.sh
Created Oct 17, 2016
Magento 1.9.3 Free Shipping Sales Rule Fix
View patch.sh
diff --git a/app/code/core/Mage/SalesRule/etc/config.xml b/app/code/core/Mage/SalesRule/etc/config.xml
index d5e7763..6a0e898 100644
--- a/app/code/core/Mage/SalesRule/etc/config.xml
+++ b/app/code/core/Mage/SalesRule/etc/config.xml
@@ -134,8 +134,8 @@
<totals>
<freeshipping>
<class>salesrule/quote_freeshipping</class>
- <after>subtotal,tax_subtotal</after>
- <before>shipping</before>
@andrew-smart
andrew-smart / bin-magento.sh
Last active Jun 21, 2016
Run bin/magento from anywhere in your Magento 2 installation
View bin-magento.sh
#!/usr/bin/env bash
# Detect magento
#
# Adapted from Alan Storms approach
# to finding the Magento root by traversing up from the current
# directory checking for the existence of the di.xml file.
#
# Ref: https://github.com/astorm/pestle/blob/master/modules/pulsestorm/magento2/cli/library/module.php#L57
di="app/etc/di.xml"
@andrew-smart
andrew-smart / magento2-create-project.sh
Created Feb 18, 2016
Create a new project in Magento 2
View magento2-create-project.sh
#!/usr/bin/env bash
name=$1
if [ -z "$name" ]; then
echo "\$name required"
exit 1
fi
path=$(eval echo "~/Sites/$name")
if [ -d "$path" ]; then
echo "$path already exists. Aborting"
@andrew-smart
andrew-smart / di.xml
Created Jan 18, 2016
Magento 2: Declare a plugin
View di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="[ObservedType]">
<plugin name="[pluginName]" type="[PluginClassName]" sortOrder="1" disabled="false" />
</type>
</config>
@andrew-smart
andrew-smart / .gitignore
Last active Dec 10, 2015
Magento 2 .gitignore
View .gitignore
/app/design/*/Magento
/app/etc
/app/*.*
/bin/
/dev/
/lib/
/phpserver/
/pub/
/setup/
/update/
@andrew-smart
andrew-smart / .htaccess
Created Oct 6, 2015
HTTP to HTTPS redirect
View .htaccess
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_METHOD} !=POST
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@andrew-smart
andrew-smart / subs.php
Created Sep 4, 2015
Get product categories under a particular parent (Magento 1.x)
View subs.php
<?php
function getSubs($product, $parentId)
{
$cats = array();
// get the product category ids
$ids = $product->getCategoryIds();
// get all children of the parent $catId
@andrew-smart
andrew-smart / config.php
Created Jul 9, 2015
HelloWorld sample config file (Magento 2)
View config.php
<?php
return array(
'modules' => array(
...
'Magento_CurrencySymbol' => 1,
'Magento_Wishlist' => 1,
'Iweb_HelloWorld' => 1
)
);
@andrew-smart
andrew-smart / module.xml
Last active Aug 29, 2015
Registration (module.xml) file sample (Magento 2.x)
View module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="[Vendor]_[ModuleName]" setup_version="0.0.0.1"/>
</config>
@andrew-smart
andrew-smart / config.xml
Created Feb 27, 2015
Expose a modules crontab schedule to system configuration (Magento 1.x)
View config.xml
<?xml version="1.0"?>
<config>
...
<crontab>
<jobs>
<[namespace]_cron>
<schedule>
<!--
/**
*