Skip to content

Instantly share code, notes, and snippets.

View antoinekociuba's full-sized avatar

Antoine Kociuba antoinekociuba

View GitHub Profile
@antoinekociuba
antoinekociuba / rsync_media
Last active July 23, 2019 23:30
rsync Magento media folder from a remote server to a local media directory
rsync -avz --dry-run SOURCE DESTINATION
rsync -avz --dry-run SSH_USER@IP:/REMOTE_ASBOLUTE_PATH/media/ media/
--dry-run is to test if everything is fine, always do it first ;p
Remove it then to launch the real action
@antoinekociuba
antoinekociuba / git-clone-non-empty-directory.sh
Created October 11, 2016 17:19
GIT - Clone into a non-empty directory
git init
git remote add origin PATH/TO/REPO
git fetch
git checkout -t origin/master
@antoinekociuba
antoinekociuba / disable_products_without_image.sql
Last active October 11, 2016 17:20
Magento - Disable configurable products without image, through SQL direct query
UPDATE catalog_product_entity_int SET value = 2
WHERE attribute_id = (
SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'status' AND entity_type_id = (
SELECT entity_type_id FROM eav_entity_type WHERE entity_type_code = 'catalog_product'
)
)
AND entity_id IN (
SELECT catalog_product_entity.entity_id
FROM catalog_product_entity_media_gallery
RIGHT OUTER JOIN catalog_product_entity ON catalog_product_entity.entity_id = catalog_product_entity_media_gallery.entity_id
@antoinekociuba
antoinekociuba / gist:f136d817c22cd750dc252a4434cc72f4
Created July 7, 2016 15:54
Flush Magento EE url rewrites (>= 1.13) + Rebuild
# SQL Query
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `enterprise_url_rewrite_redirect_rewrite`;
TRUNCATE TABLE `enterprise_url_rewrite_redirect_cl`;
TRUNCATE TABLE `enterprise_url_rewrite_redirect`;
TRUNCATE TABLE `enterprise_url_rewrite_product_cl`;
TRUNCATE TABLE `enterprise_url_rewrite_category_cl`;
TRUNCATE TABLE `enterprise_url_rewrite`;
TRUNCATE TABLE `enterprise_catalog_product_rewrite`;
TRUNCATE TABLE `enterprise_catalog_category_rewrite`;
@antoinekociuba
antoinekociuba / update_emails.sql
Created October 2, 2015 13:01
Update customer/order email addresses in test environment database (prevent to accidentally send test emails to real customers)
## Update order email addresses ##
UPDATE `sales_flat_order`
SET `customer_email` = CONCAT('test__', `customer_email`)
WHERE `customer_email` NOT IN ('[email protected]', '[email protected]')
AND `customer_email` NOT LIKE 'test__%';
## Update customer email addresses ##
UPDATE `customer_entity`
SET `email` = CONCAT('test__', `email`)
WHERE `email` NOT IN ('[email protected]', '[email protected]')
@antoinekociuba
antoinekociuba / disable_enable_ee_index.php
Last active March 23, 2016 07:38
Disable/Enable EE index updates (might be useful during a script execution to speed it up...)
<?php
/**********************
****** DISABLE *******
**********************/
/** var Mage_Core_Model_Config $config */
$config = Mage::app()->getConfig();
/**
@antoinekociuba
antoinekociuba / full_reindex.php
Last active March 23, 2016 07:37
Magento full reindex script (EE compatible)
<?php
/** Full reindex script */
/**
* @var array
*/
$processes = array();
/**
* @var Mage_Core_Model_Factory $factory
@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
@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 / 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();