Skip to content

Instantly share code, notes, and snippets.

View jamescowie's full-sized avatar

James Cowie jamescowie

View GitHub Profile
@jamescowie
jamescowie / gist:7295210
Created November 3, 2013 21:46
Show login / logout links Laravel 4
@if ( Auth::guest() )
<li>{{ HTML::link('login', 'Login') }}</li>
@else
<li>{{ HTML::link('logout', 'Logout') }}</li>
@endif
@jamescowie
jamescowie / gist:cdfe90d9557e467ab008
Created July 20, 2014 20:00
Custom attribute assertion
$model = \Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
$model->setHighestOnlinePrice($highestPrice); // This attribute does NOT exist in Magento
$model->save();
PHPUnit_Framework_Assert::assertTrue($model->offsetExists('highest_online_price'));
<?php
@method string getProductName() getProductName(int $id) Return string value for product name
class Jcowie_PHPSpec_Model_Product extends Mage_Core_Model_Abstract
{
public function _construct()
{
$this->_init('phpspec/product');
}
SET FOREIGN_KEY_CHECKS=0;
-- reset customers
TRUNCATE customer_address_entity;
TRUNCATE customer_address_entity_datetime;
TRUNCATE customer_address_entity_decimal;
TRUNCATE customer_address_entity_int;
TRUNCATE customer_address_entity_text;
TRUNCATE customer_address_entity_varchar;
TRUNCATE customer_entity;
TRUNCATE customer_entity_datetime;
@jamescowie
jamescowie / Magento CMS block
Created February 2, 2015 15:57
Check if CMS block is enabled or not
<?php
Mage::getModel('cms/block')->load('static_block_identifier')->getIsActive()
Hello World from CLI
@jamescowie
jamescowie / magento2.markdown
Last active August 29, 2015 14:22
Installing Magento 2 / Magento 2 module workflow.

Installing Magento 2

Im exploring the different ways that can be used to install Magento 2 both locally for extension development and then how this could be deployed into production.

Warning this will be a evolving living gist as I have time to play around.

Using composer to create the project

I found that I could run:

composer create project magento/project-community-edition=dev-master magento2

Keybase proof

I hereby claim:

  • I am jamescowie on github.
  • I am jcowie (https://keybase.io/jcowie) on keybase.
  • I have a public key whose fingerprint is C346 4D1C AC9F 12F9 E85B C081 F5DA 2598 AFEB 95E8

To claim this, I am signing this object:

@jamescowie
jamescowie / -
Created November 11, 2015 02:20
test
@jamescowie
jamescowie / -
Created November 11, 2015 02:21
test