Skip to content

Instantly share code, notes, and snippets.

/**
* Set prices and image configuration
*
* @param Varien_Event_Observer $observer
*/
public function salesQuoteCollectTotalsBefore(Varien_Event_Observer $observer)
{
/* @var $quote Mage_Sales_Model_Quote */
$quote = $observer->getQuote();
foreach ($quote->getAllItems() as $quoteItem) {
@nhp
nhp / allthethings.sh
Created July 28, 2018 20:25 — forked from TravisBernard/allthethings.sh
Clean all the things (M2)
#!/bin/bash
# Derived from
# https://github.com/btford/allthethings
#
# Licensed under WTFPL http://sam.zoy.org/wtfpl/
#
pur=$(tput setaf 5) # Purple
@nhp
nhp / s3-latest.sh
Created May 15, 2018 16:00
get latest file from given s3-bucket. Call it with ./s3-latest buckename foldername
#!/bin/bash
KEY=`aws s3 ls s3://$1/$2 --recursive | sort | tail -n 1 | awk '{print $4}'`
aws s3 cp s3://$1/$KEY ./$(basename $KEY)
@nhp
nhp / glacier.sh
Last active December 30, 2019 09:43
aws glacier upload from bash with correctly configured aws cli credits to https://github.com/dradtke
#!/bin/bash
#
# This script takes a path to a file and uploads it to Amazon
# Glacier. It does this in several steps:
#
# 1. Split the file up into 1MiB chunks.
# 2. Initiate a multipart upload.
# 3. Upload each part individually.
# 4. Calculate the file's tree hash and finish the upload.
#
@nhp
nhp / Mage_Eav_Model_Entity_Abstract
Created October 6, 2017 11:16 — forked from dng-dev/Mage_Eav_Model_Entity_Abstract
improves eav based loads
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@nhp
nhp / Mage_Eav_Model_Entity_Abstract
Created October 6, 2017 11:16 — forked from dng-dev/Mage_Eav_Model_Entity_Abstract
improves eav based loads
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@nhp
nhp / deploy.php
Last active October 24, 2016 08:24
Deployer task to create release in jira
task('deploy:jira:release', function() {
$curl = curl_init();
curl_setopt_array($curl, [
//change this to your data
CURLOPT_URL => "https://company-cloud-name.atlassian.net/rest/api/latest/version",
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_POST => 1,
CURLOPT_HTTPHEADER => array('Content-type: application/json'),
//change this to your data
CURLOPT_USERPWD => 'user:password',
@nhp
nhp / Magento\Framework\Console\Cli
Created April 27, 2016 17:57 — forked from antonkril/Magento\Framework\Console\Cli
Hackathon Extension Point for Setup App
<?php
namespace Magento\Framework\Console;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Application as SymfonyApplication;
use Magento\Framework\App\Bootstrap;
use Magento\Framework\Filesystem\Driver\File;
@nhp
nhp / custom_adminurl_fix.patch
Created November 9, 2015 10:31
custom AdminUrl Fix without bc breaks
diff --git a/app/code/core/Mage/Adminhtml/controllers/IndexController.php b/app/code/core/Mage/Adminhtml/controllers/IndexController.php
index 5c786d5..b99705a 100644
--- a/app/code/core/Mage/Adminhtml/controllers/IndexController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/IndexController.php
@@ -75,6 +75,11 @@ class Mage_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
$this->_redirect('*');
return;
}
+ if (!in_Array(Mage::getConfig()->getNode(Mage_Adminhtml_Helper_Data::XML_PATH_ADMINHTML_ROUTER_FRONTNAME), explode(DS, $this->getRequest()->getRequestUri()))) {
+ $this->_redirect('cms/index/noRoute');
@nhp
nhp / Observer.php
Last active December 15, 2016 17:27 — forked from bastianccm/Observer.php
<?php
/**
* Class Extra_Static_Model_Observer
*
* @category Model
* @package Extra_Static
* @author AOE Magento Team <[email protected]>
* @license none none
* @link www.aoe.com