Skip to content

Instantly share code, notes, and snippets.

View jzahedieh's full-sized avatar

Jonathan Zahedieh jzahedieh

View GitHub Profile
@jzahedieh
jzahedieh / README.md
Last active April 18, 2016 12:09 — forked from chadrien/README.md
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
@jzahedieh
jzahedieh / gist:8af77c84418ad9c354cf
Created March 31, 2015 14:12
Magento CONCAT EAV Attributes
$collection = Mage::getModel('customer/address')->getCollection();
$collection->addAttributeToSelect('*');
$collection->addExpressionAttributeToSelect(
'full_address',
"CONCAT({{firstname}}, {{lastname}}, {{street}}, {{city}}, {{postcode}})",
array('firstname', 'lastname', 'street', 'city', 'postcode')
);
import itertools
# given I have a list from 1-16
# group evenly balanced pairs
players = list(range(1, 13))
N = 4
groupNo = len(players) / 4
print(groupNo)
@jzahedieh
jzahedieh / composer.json
Last active August 29, 2015 14:07
PHPUnit composer magento file
{
"require": {
"magento-hackathon/magento-composer-installer":"*"
},
"require-dev": {
"ecomdev/ecomdev_phpunit": "dev-master",
"mikey179/vfsStream": ">=1.2.0",
"firegento/psr0autoloader": "dev-master"
},
"repositories": [
@jzahedieh
jzahedieh / svn_gitignore.sh
Last active August 29, 2015 14:07
Base script that adds svn:ignore from a .gitignore file
#!/bin/bash
FileArray=()
while read line
do
# starts and ends with a slash (folder)
if [[ ${line} == /* ]] && [[ ${line} == */ ]]; then
path=${line#?} # strip first slash
echo "Processing Folder: ${path}"
# loop over all directories so we can make sure they are all added
@jzahedieh
jzahedieh / .gitignore
Last active February 12, 2016 16:28
Magento EE 1.14 .gitignore
# default magento folders
/downloader/
/errors/
/includes/
/lib/
/media/
/pkginfo/
/shell/
/var/
/vendor/
@jzahedieh
jzahedieh / website_generator.php
Created September 1, 2014 13:31
Website generator with products
<?php
set_time_limit(0);
require_once 'abstract.php';
class Website_Generator extends Mage_Shell_Abstract
{
protected $_start = 1;
protected $_create = 5000;
public function run()
@jzahedieh
jzahedieh / customer-install-0.1.0.php
Last active December 27, 2018 16:30
Magento Customer Attribute Setup
<?php
/* @var $installer Mage_Customer_Model_Resource_Setup */
$installer = Mage::getResourceModel('customer/setup','customer_setup');
$installer->startSetup();
if (!$installer->getAttributeId('customer', 'attribute_name')) {
$installer->addAttribute('customer', 'attribute_name', array( // TABLE.COLUMN: DESCRIPTION:
/** Standard values defined @see Mage_Eav_Model_Entity_Setup::_prepareValues() */
'label' => 'Label', // eav_attribute.frontend_label admin input label
'backend' => 'module/class_name', // eav_attribute.backend_model backend class (module/class_name format)
@jzahedieh
jzahedieh / product-install-0.1.0.php
Last active December 26, 2018 21:17
Magento Product Attribute Setup
<?php
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
if (!$installer->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'attribute_name')) {
$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'attribute_name', array( // TABLE.COLUMN: DESCRIPTION:
/** Standard values defined @see Mage_Eav_Model_Entity_Setup::_prepareValues() */
'label' => 'Label', // eav_attribute.frontend_label admin input label
'backend' => 'module/class_name', // eav_attribute.backend_model backend class (module/class_name format)
'type' => 'varchar', // eav_attribute.backend_type backend storage type (varchar, text etc)
<?php
/**
* Functionality taken from Mage_ImportExport_Model_Import_Entity_Product
*/
class Your_Module_Model_Category_Finder
{
/**
* Categories text-path to ID hash.
*
* @var array