Skip to content

Instantly share code, notes, and snippets.

Avatar

Claudiu Marginean claudiu-marginean

View GitHub Profile
@claudiu-marginean
claudiu-marginean / MockeryMockIterator.php
Last active May 24, 2018 — forked from pgraham/gist:4127832
function to create a mock iterator over an array using PHP Mockery lib
View MockeryMockIterator.php
/**
* Create a mock iterator over the given array.
*
* @param array $a
* @param string $class The class to use for the mock, should be/implement/extend Iterator
* @param boolean $complete Whether or not to build a complete iteration. This is
* used when an exception/break is expected in the middle of the iteration.
* @param integer $numElms The number of elements that should be iterated in the case of an
* incomplete iteration.
*/
View change_eav_attribute_type.sql
#
# Change EAV Attribute Type from dropdown to multipleselect
# - copy old attribute values to new table
#
dropdown attribute_id = 137
UPDATE eav_attribute SET
backend_model = 'eav/entity_attribute_backend_array',
frontend_input = 'multiselect',
@claudiu-marginean
claudiu-marginean / js_translate.phtml
Last active Sep 1, 2015
Magento 1.x JS Translation in template files
View js_translate.phtml
<script>
//<![CDATA[
Translator.add(
<?php echo Mage::helper('core')->jsonEncode(array(
'Please use letters only.' => $this->__('Please use letters only.'),
'Please use letters only.' => $this->helper('jstranslate')->__('Please use letters only.'),
)) ?>
);
//]]>
</script>
@claudiu-marginean
claudiu-marginean / info
Last active Aug 29, 2015
GIT - Assume Unchanged
View info
Aveti aici niste comenzi foarte utile pentru situatiile in care vreti sa evitati sa faceti in mod repetat stash-uri la o serie de fisiere de configurari locale, pe care nu trebuie nici sa le comiteti pe un proiect, si nici sa le puneti in gitignore pentru ca fisierele exista si sunt necesare pe branchurile superioare.
In aceste cazuri puteti folosi:
### Pentru a opri tracking-ul fisierului
```git update-index --assume-unchanged <file>```
On Windows use:
```git ls-files -v | grep "^[a-z]"```
@claudiu-marginean
claudiu-marginean / httpd-vhosts.conf
Last active Aug 29, 2015 — forked from anonymous/httpd-vhosts.conf
VirtualHost in XAMPP with https (with certif from localhost)
View httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "D:/www/project-name"
ServerName local.project-name.net
ServerAlias local.project-name.net
#SetEnv MAGE_IS_DEVELOPER_MODE "true"
<Directory "D:/www/project-name">
Options Indexes FollowSymLinks
AllowOverride All
View gist:7724599

Git Ignore - Global

Path to this depends on you global git config "excludesfile".

Mine is: excludesfile = C:\\www\\gitignore_global.txt

#IDE project files
/.idea
#composer files and lib folder
/vendor
View Magento-Snippets-Claudiu.md

Magento Snippets

Code snippets from different sections of Magento that are very useful.

JS Translation in phtml files

<script>
//<![CDATA[
Translator.add(
    <?php echo Mage::helper('core')->jsonEncode(array(
@claudiu-marginean
claudiu-marginean / update_product_attribute
Last active Dec 12, 2015
Update Product Attributes
View update_product_attribute
<?php
/**
* This code only updates the attributes you want to change.
* The first paramater is an array of product IDs,
* the second is an array of attribute names and values,
* and then the third is the store ID you wish to update.
* This is MUCH faster than saving the entire model.
* Ref Link: http://stackoverflow.com/questions/3669211/saving-in-magento-taking-a-very-very-long-time
*/
@claudiu-marginean
claudiu-marginean / Magento Subversion ignore.txt
Created Apr 21, 2012
Magento Subversion .ignore files and directors
View Magento Subversion ignore.txt
Copy From https://github.com/davidalexander/Magento-Documents/blob/master/Magento%20.gitignore.txt
@author davidalexander
#####################################################################
# files that should be custom to environment (live/dev/staging/etc) #
#####################################################################
/.htaccess
/app/etc/local.xml
#####################
You can’t perform that action at this time.