Skip to content

Instantly share code, notes, and snippets.

View antoinekociuba's full-sized avatar

Antoine Kociuba antoinekociuba

View GitHub Profile
@antoinekociuba
antoinekociuba / tar_magento_media_folder.sh
Created August 3, 2014 12:57
Command to Tar Magento media folder, excluding unwanted files/folders. This command needs to be run on your magento installation root folder.
tar -zcvf var/backups/media_$(date +%d%m%Y).tar.gz --exclude-vcs --exclude='*cache*' --exclude='captcha' --exclude='wysiwyg/.thumbs' --exclude='tmp' --exclude='import' --exclude='export' --exclude='js' --exclude='js_secure' --exclude='css' --exclude='css_secure' media/
@antoinekociuba
antoinekociuba / robots.txt
Last active May 25, 2016 22:24
Magento robots.txt template.
## Website Sitemap
# Sitemap: http://www.example.com/sitemap.xml
## Crawlers Setup
User-agent: *
# Crawl-delay: 30
## Do not crawl common Magento folders
Disallow: /app/
Disallow: /downloader/
@antoinekociuba
antoinekociuba / cms_blocks_installer.php
Last active October 20, 2015 12:38
Magento CMS Blocks installer script (useful to deploy safely).
<?php
/**
* CMS Blocks Installer
*/
try {
/* @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;
$block1Content = <<<HTML
@antoinekociuba
antoinekociuba / cms_pages_installer.php
Last active October 26, 2015 11:25
Magento CMS Pages installer script (useful to deploy safely).
<?php
/**
* CMS Pages Installer
*/
try {
/* @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;
$page1Content = <<<HTML
@antoinekociuba
antoinekociuba / product_attribute_sets_installer.php
Created August 3, 2014 15:15
Magento Product Attribute Sets installer script.
<?php
/**
* Product Attribute Sets Installer
*/
/* @var $installer Mage_Catalog_Model_Resource_Setup */
$installer = $this;
// Default attribute set
$defaultAttributeSetId = $installer->getAttributeSetId(Mage_Catalog_Model_Product::ENTITY, 'Default');
@antoinekociuba
antoinekociuba / shopping_cart_sales_rule_with_coupon.php
Last active September 16, 2023 11:00
Magento - Create shopping cart price rule with a specific coupon code programmatically.
<?php
/**
* Create Shopping Cart Sales Rule with Specific Coupon Code Programmatically
*/
// All customer group ids
$customerGroupIds = Mage::getModel('customer/group')->getCollection()->getAllIds();
// SalesRule Rule model
$rule = Mage::getModel('salesrule/rule');
@antoinekociuba
antoinekociuba / product_attribute_installer.php
Created August 3, 2014 22:48
Magento Product Attribute installer script.
<?php
/**
* Product Attribute Installer
*/
try {
/* @var $installer Mage_Catalog_Model_Resource_Setup */
$installer = $this;
$installer->startSetup();
@antoinekociuba
antoinekociuba / customer_attributes_installer.php
Created August 3, 2014 22:54
Magento Customer/Customer Address Attributes installer script (for Community Edition).
<?php
/**
* Customer/Customer Address Attributes Installer
*/
try {
/* @var $installer Mage_Customer_Model_Entity_Setup */
$installer = $this;
$installer->startSetup();
@antoinekociuba
antoinekociuba / observer.php
Last active August 29, 2015 14:04
Display out of stock options of Configurable products, depending on 'Show out of stock' system configuration setting.
<?php
/**
* Check if out of stock options of configurable products should be displayed
*/
public function checkDisplayOutOfStockOptions()
{
$currentProduct = Mage::registry('current_product');
if ($currentProduct && $currentProduct->isConfigurable()) {
if (Mage::getStoreConfigFlag(Mage_CatalogInventory_Helper_Data::XML_PATH_SHOW_OUT_OF_STOCK)) {
@antoinekociuba
antoinekociuba / Composer
Last active August 29, 2015 14:06
PHP Code Sniffer/PHP Mess Detector - composer.json
############################################################
# From the directory which contains the composer.json file #
############################################################
curl -s http://getcomposer.org/installer | php
php composer.phar install