Skip to content

Instantly share code, notes, and snippets.

@erfanimani
erfanimani / prepare-magento-deployment
Last active Jun 5, 2016
Prepare Magento deployment hook for Envoyer.io (Install Composer Dependencies - After)
View prepare-magento-deployment
cd {{project}}
mkdir -p storage/media
mkdir -p storage/var
chmod -fR g+w storage || true
cp -rTv {{release}}/docroot/media/ storage/media/
cp -rTv {{release}}/docroot/var/ storage/var/
rm -r {{release}}/docroot/media
View table_size.sql
SELECT
TABLE_NAME, table_rows, data_length, index_length,
round(((data_length + index_length) / 1024 / 1024),2) 'Size in MB'
FROM information_schema.TABLES
WHERE table_schema = 'yourSchemaName' and TABLE_TYPE='BASE TABLE'
ORDER BY data_length DESC;
@erfanimani
erfanimani / MyResourceModel.php
Created Dec 29, 2014
Magento: Setting update and creation date for resource models
View MyResourceModel.php
protected function _prepareDataForSave(Mage_Core_Model_Abstract $object)
{
$currentTime = Varien_Date::now();
if ((!$object->getId() || $object->isObjectNew()) && !$object->getCreatedAt()) {
$object->setCreatedAt($currentTime);
}
$object->setUpdatedAt($currentTime);
$data = parent::_prepareDataForSave($object);
return $data;
}
@erfanimani
erfanimani / all.conf
Created Apr 20, 2014
Simple Apache2.2 configuration that allows you to use deployments through git for very basic sites.
View all.conf
<Directory /var/www>
Order Deny,Allow
Allow from all
AllowOverride All
</Directory>
<Directorymatch "^/.*/\.git/">
Order deny,allow
Deny from all
</Directorymatch>
@erfanimani
erfanimani / .gitignore
Last active Jun 1, 2019
A refactored and modern .gitignore for Magento. Compatible for Git versions 2.7.0+. See this revision to use it for versions lower than 2.7.0: https://gist.github.com/erfanimani/8856964/886f5d79d229c21b9c712155c362e5fc1c61a12a
View .gitignore
### MAGENTO DIRECTORIES
# Ignore everything in media, except for the htaccess files
# Also include the Lazy Catalog Images (LCI) .htaccess if that's installed
# (https://github.com/AOEpeople/Aoe_LazyCatalogImages)
/media/*
!/media/.htaccess
!/media/customer/.htaccess
!/media/downloadable/.htaccess
!/media/catalog/product/LCI/.htaccess
You can’t perform that action at this time.