Skip to content

Instantly share code, notes, and snippets.

View eniuz's full-sized avatar

Mariusz Szot eniuz

View GitHub Profile
@eniuz
eniuz / create-category-attribute.php
Created March 15, 2016 13:35
Create Category Attribute
<?php
$attributeUtility = Mage::getModel('core/setup');
$attributeUtility->addAttribute('catalog_category', 'attribute_code',
array(
'sort_order' => '0',
'backend_type' => 'int',
'input' => "boolean",
'label' => 'Custom Attribute Label',
'source_model' => 'eav/entity_attribute_source_boolean',
@eniuz
eniuz / install-hhvm-centos7.sh
Created March 14, 2016 16:18
install-hhvm-centos-7
yum update -y
yum install inotify-tools
rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/i/inotify-tools-devel-3.14-8.el7.x86_64.rpm
rpm -Uvh http://mirrors.linuxeye.com/hhvm-repo/7/x86_64/hhvm-3.12.0-1.el7.centos.x86_64.rpm
@eniuz
eniuz / remove-open-short-tags.sh
Created March 10, 2016 10:42
Remove open short tags
for file in *.php
do
sed -i 's/<?$/<?php/' $file
sed -i 's/<? /<?php /' $file
done
@eniuz
eniuz / create-product-attribute.php
Created March 8, 2016 13:58
Create Product Attribute
<?php
// http://blog.chapagain.com.np/magento-adding-attribute-from-mysql-setup-file/
<?php
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
/**
* Adding Different Attributes
*/
@eniuz
eniuz / gist:526d355e190a9aa52a3e
Created March 7, 2016 17:25
find last line in csv found on stack
function getLastLine($file, $bufferSize){
$fp = fopen($file, 'r');
$size = filesize($file);
$buffer = '';
for ($pos = $size - $bufferSize; ; $pos -= $bufferSize) {
$pos = max(0, $pos);
fseek($fp, $pos);
$b = rtrim(fread($fp, $bufferSize));
$nlPos = strrpos($b, "\n");
@eniuz
eniuz / fix-indexer.sql
Created March 1, 2016 15:24
duplicated product breaks indexer
delete FROM `catalog_product_entity_datetime` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_decimal` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_gallery` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_group_price` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_int` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_media_gallery` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_text` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_tier_price` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_varchar` where entity_id not in (select entity_id fro
@eniuz
eniuz / magerun-cannot-redeclare-class.sh
Created February 5, 2016 14:07
Cannot redeclare class n98\magento\command\config\dumpcommand
php -d apc.enable_cli=0 magerun
@eniuz
eniuz / install-magerun.sh
Created January 29, 2016 15:59
Install Magerun
# install as superuser
wget http://files.magerun.net/n98-magerun-latest.phar -O magerun && chmod +x magerun && mv magerun /usr/local/bin/
@eniuz
eniuz / nginx.conf
Created January 29, 2016 12:08 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@eniuz
eniuz / create_website_scope.php
Created January 14, 2016 11:55 — forked from yireo/create_website_scope.php
Magento script to create a new Website, new Store Group, new Store View and new Root Catalog - all linked together.
<?php
// Base-name
$name = 'foobar';
// Init Magento
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
// Create the root catalog