Skip to content

Instantly share code, notes, and snippets.

View vdubyna's full-sized avatar

Volodymyr Dubyna vdubyna

View GitHub Profile
@vdubyna
vdubyna / build.properties
Created September 24, 2012 12:36
Phing magento installation
install.mysql.host=127.0.0.1
install.mysql.db=mage17_dev
install.mysql.user=root
install.mysql.password=
install.host=http://mage17.dev/
install.timezone=Europe/Kiev
install.admin.login=admin
install.admin.password=qwer1234
install.admin.email=vovikha@gmail.com
@vdubyna
vdubyna / gist:3789559
Created September 26, 2012 18:05
Change Magento attribute type
INSERT INTO catalog_product_entity_text (`attribute_id`, `entity_id`, `entity_type_id`, `store_id`, `value`)
SELECT ev.`attribute_id`, ev.`entity_id`, ev.`entity_type_id`, ev.`store_id`, ev.`value`
FROM catalog_product_entity_varchar AS ev WHERE ev.`attribute_id` = ATTRIBUTE_ID;
UPDATE `eav_attribute` SET `backend_type`='text' WHERE `attribute_code`='ATTRIBUTE_CODE';
DELETE FROM catalog_product_entity_varchar WHERE `attribute_id` = ATTRIBUTE_ID;
@vdubyna
vdubyna / Observer.php
Created September 30, 2012 10:40
Add block on the fly
<?php
class Myspace_Fpcblock_Model_Observer
{
public function prependTimeBlock($observer)
{
/** @var $layout Mage_Core_Model_Layout */
$layout = Mage::app()->getLayout();
$block = $layout->createBlock(
@vdubyna
vdubyna / ruleset.xml
Last active January 18, 2016 12:34
Magento CodeSniffer rules
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
@vdubyna
vdubyna / build.xml
Created October 23, 2012 18:58
php and teamcity
<?xml version="1.0" encoding="UTF-8"?>
<project name="Application" default="build" basedir="../">
<target name="build" depends="prepare,phpunit,phpmd,phpcpd,phpdoc,phpcb,phpdcd,phploc,phpcs"/>
<property name="applicationDir" value="${basedir}/source" />
<property name="buildDir" value="${basedir}/build" />
<target name="prepare">
<mkdir dir="${buildDir}/logs" />
@vdubyna
vdubyna / index.php
Created October 26, 2012 22:19
Profile db queries
Mage::run($mageRunCode, $mageRunType);
//Insert code after Mage run
/** @var $profiler Zend_Db_Profiler */
$profiler = Mage::getSingleton('core/resource')->getConnection()->getProfiler();
$log = date('Y-m-d_H:i:s') . uniqid();
Mage::log('Total queries: ' . count($profiler->getQueryProfiles()), null, $log);
Mage::log('Total sec: ' . $profiler->getTotalElapsedSecs(), null, $log);
foreach ($profiler->getQueryProfiles() as $query) {
/** @var $query Zend_Db_Profiler_Query */
Mage::log($query->getElapsedSecs() . "\n" .$query->getQuery() . "\n" . print_r($query->getQueryParams(), 1), null, $log);
@vdubyna
vdubyna / checklist.txt
Created November 8, 2012 13:48
Checklist to approve magento module
- Code 100% Rules compliance in sonar
- Registered in Module Repository (according to the rules)
@vdubyna
vdubyna / bootstrap.php
Created November 9, 2012 13:28
Generate magento products
<?php
// file location dev/bootstrap.php
require_once dirname(__FILE__) . '/../app/Mage.php';
error_reporting(E_ALL);
ini_set('display_errors', '1');
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
<?xml version="1.0" encoding="UTF-8"?>
<project name="Build lasenza application" default="default">
<property file="build.properties" />
<property name="application.dir" value="${project.basedir}/.." />
<property name="build.dir" value="${project.basedir}/build" />
<target name="default">
<input propertyName="input.db.user" message="Input DB user" defaultValue="root" />
<input propertyName="input.db.host" message="Input DB host" defaultValue="localhost" />
<?php
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Behat\BehatBundle\Command\BehatCommand;
class BehatTest extends KernelAwareTest
{
/**