Skip to content

Instantly share code, notes, and snippets.

View rootindex's full-sized avatar

rootindex rootindex

  • Silvertree
  • Cape Town
View GitHub Profile
public function createVoucher($value=0, $cardnumber){
$voucher_id = Mage::getModel('salesrule/coupon')->load($cardnumber . '-' . Mage::helper('checkout')->getQuote()->getId(), 'code');
if($voucher_id->getRuleId()){
$cartpriceRule = Mage::getModel('salesrule/rule')->load($voucher_id->getRuleId());
$cartpriceRule->setDiscountAmount($value);
}else{
$cartpriceRule = Mage::getModel('salesrule/rule');
$cartpriceRule->setName('Giftcard '. $cardnumber);
$cartpriceRule->setDescription('Giftcard '. $cardnumber);
$installer = $this;
$installer->startSetup();
$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'brand', array(
'group' => 'General',
'attribute_set' => 'Default',
'type' => 'int',
'label' => 'Brand',
'input' => 'select',
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
//#include <sendproxy>
#define WATER_LEVEL_DRY 0
#define WATER_LEVEL_FEET 1
#define WATER_LEVEL_HALF 2
#define WATER_LEVEL_FULL 3
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <colours>
#pragma semicolon 1
public Plugin:myinfo =
{
<?xml version = "1.0" encoding = "UTF-8" ?>
<schema name="yes" version="1.5">
<types>
<fieldType name="string" class="solr.StrField" sortMissingLast="true"/>
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="text" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<?xml version = "1.0" encoding = "UTF-8" ?>
<schema name="yes" version="1.5">
<types>
<fieldType name="string" class="solr.StrField" sortMissingLast="true"/>
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="text" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
@rootindex
rootindex / MaintenanceMode.php
Last active January 11, 2016 09:27
Magento2 Maintenance Mode
<?php
// 1) Enabled maintenance mode by creating file .maintenance.flag in the var folder
// 2) By pass maintenance mode by creating file .maintenance.ip in the var folder
// 3) IP addresses does not work for ranges only individual ip addresses
if (!preg_match('/^[^\s,]+(,[^\s,]+)*$/', $addresses)) {
throw new \InvalidArgumentException("One or more IP-addresses is expected (comma-separated)\n");
}
@rootindex
rootindex / magento.sh
Last active January 11, 2016 09:43
Show mode and change mode
#!/bin/sh
magento deploy:mode:show
Current application mode: default.
magento deploy:mode:set developer
Enabled developer mode.
@rootindex
rootindex / install.sh
Created January 11, 2016 09:42
Install Magento2 with composer
#!/bin/sh
# specify directory if not in it
composer create-project magento/community-edition .
# Fix file permissions
find . -type d -exec chmod 700 {} \; && find . -type f -exec chmod 600 {} \;
# execute if you have not done so in the past
composer config repositories.magento composer http://packages.magento.com
@rootindex
rootindex / log.php
Created January 11, 2016 14:29
Including logger
<?php
class Blah {
protected $_logger;
public function __construct(
\Psr\Log\LoggerInterface $logger
){
$this->_logger = $logger;