Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
Deep in the code

Javier Villanueva jahvi

👨‍💻
Deep in the code
View GitHub Profile
@jahvi
jahvi / Vagrantfile
Last active Sep 6, 2015
Basic Vagrantfile
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# OS to install on VM
config.vm.box = "ubuntu/trusty64"
# IP to access VM
config.vm.network "private_network", ip: "192.168.33.10"
@jahvi
jahvi / Vagrantfile
Last active Sep 6, 2015
Install apache in Ubuntu Server
View Vagrantfile
# Update repository
config.vm.provision "shell", inline: "sudo apt-get update"
# Install apache
config.vm.provision "shell", inline: "sudo apt-get install -qq apache2"
@jahvi
jahvi / system.xml
Created Sep 27, 2015
Option configuration for Limit Minimum Order extension
View system.xml
<?xml version="1.0"?>
<config>
<sections>
<cataloginventory>
<groups>
<options>
<fields>
<min_total_qty translate="label">
<label>Minimum Qty Allowed in Shopping Cart</label>
<frontend_model>cataloginventory/adminhtml_form_field_minsaleqty</frontend_model>
@jahvi
jahvi / config.xml
Created Sep 27, 2015
Module configuration for Limit Minimum Order extension
View config.xml
<?xml version="1.0"?>
<config>
<modules>
<Jvs_MinTotalQty>
<version>1.0.0</version>
</Jvs_MinTotalQty>
</modules>
<global>
<models>
<jvs_mintotalqty>
@jahvi
jahvi / Observer.php
Created Sep 27, 2015
Limit Minimum Order observer
View Observer.php
<?php
class Jvs_MinTotalQty_Model_Observer
{
public function checkTotalQtyBeforeCheckout(Varien_Event_Observer $observer)
{
$quote = $observer->getDataObject();
$customer = Mage::helper('customer')->getCustomer();
// If the minimun total quantity is not met
// redirect to cart page with error message
@jahvi
jahvi / Data.php
Created Sep 27, 2015
Limit Minimum Order Helper
View Data.php
<?php
class Jvs_MinTotalQty_Helper_Data extends Mage_CatalogInventory_Helper_Minsaleqty
{
const XML_PATH_MIN_TOTAL_QTY = 'cataloginventory/options/min_total_qty';
/**
* Retrieve min_total_qty value from config
*
* @param int $customerGroupId
* @param mixed $store
@jahvi
jahvi / local.xml
Created Sep 27, 2015
Limit Minimum Order local.xml
View local.xml
<?xml version="1.0"?>
<config>
<modules>
<Jvs_MinTotalQty>
<active>true</active>
<codePool>community</codePool>
</Jvs_MinTotalQty>
<depends>
<Mage_CatalogInventory/>
</depends>
@jahvi
jahvi / config.xml
Created Nov 1, 2015
Register Admin routes (Deprecated)
View config.xml
<admin>
<routers>
<custom_module>
<use>admin</use>
<args>
<module>custom_module</module>
<frontName>custom_module</frontName>
</args>
</custom_module>
</routers>
@jahvi
jahvi / config.xml
Created Nov 1, 2015
Register Admin Routes
View config.xml
<admin>
<routers>
<adminhtml>
<args>
<modules>
<custom_module after="Mage_Adminhtml">CustomModule_Adminhtml</custom_module>
</modules>
</args>
</adminhtml>
</routers>
@jahvi
jahvi / collection.php
Created Nov 1, 2015
SQL statment filter
View collection.php
<?php
$expression = '(field1 - field2)';
$condition = $this->_getConditionSql($expression, array('eq' =>3 ));
$this->_select->where($condition);
// or..
$collection->addFieldToFilter('field', array('eq' => 3));
You can’t perform that action at this time.