Skip to content

Instantly share code, notes, and snippets.

View aleron75's full-sized avatar

Alessandro Ronchi aleron75

View GitHub Profile
@aleron75
aleron75 / shell_delete_unused_images
Last active October 24, 2023 19:59
Delete no more used Product Images on Magento 1
<?php
require_once 'abstract.php';
class Mage_Shell_CheckImages extends Mage_Shell_Abstract
{
const CATALOG_PRODUCT = '/catalog/product';
const CACHE = '/cache/';
protected function _glob_recursive($pattern, $flags = 0)
@aleron75
aleron75 / env.php
Last active April 15, 2020 13:29
Admin session config values for Magento 2 local development environment
<?php
// app/etc/env.php
return [
// ...
'system' => [
'default' => [
'admin' => [
'security' => [
'session_lifetime' => 31536000,
'password_reset_protection_type' => 0,
@aleron75
aleron75 / collection_copy
Created February 20, 2015 08:42
Copy a Magento collection
$originalCollection = Mage::getModel('catalog/product')
->getCollection();
$newCollection = Mage::getModel('catalog/product')
->getCollection();
$selectParts = array(
Varien_Db_Select::DISTINCT,
Varien_Db_Select::COLUMNS,
Varien_Db_Select::UNION,
@aleron75
aleron75 / rt_admin
Last active August 23, 2019 00:41
Magento runtime for Administrator
<?php
// Prevent this script to be called via HTTP
if (isset($_SERVER['REQUEST_METHOD']))
{
die('Permission denied.');
}
// Avoid any time limit
set_time_limit(0);
@aleron75
aleron75 / rt_customer
Last active August 23, 2019 00:41
Magento runtime for Customer
<?php
// Prevent this script to be called via HTTP
if (isset($_SERVER['REQUEST_METHOD']))
{
die('Permission denied.');
}
// Avoid any time limit
set_time_limit(0);
@aleron75
aleron75 / product_count.php
Created June 10, 2016 21:03
Magento 2 - get product collection count via runtime
<?php
try {
require __DIR__ . '/app/bootstrap.php';
} catch (\Exception $e) {
echo $e->getMessage() . PHP_EOL;
exit(1);
}
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */
@aleron75
aleron75 / gist:7304592
Last active May 18, 2018 15:57
Programmaticalli create a Yes/No Magento Category Attribute
<?php
/** @var Mage_Eav_Model_Entity_Setup $installer */
$installer = $this;
$installer->startSetup();
$this->addAttribute(
'catalog_category',
'my_custom_attribute',
array(
'group' => 'General Information',
@aleron75
aleron75 / composersize.sh
Last active January 17, 2018 19:08
Shell script to "composerize" a Magento module
#!/bin/bash
function help {
echo "Arguments:"
echo " package name"
echo " package description"
}
dir=$(pwd)
@aleron75
aleron75 / Config.php
Last active August 8, 2017 10:39
Set global config value in Magento 1
Mage::getConfig()->saveConfig(Bitbull_Multiwarehouse_Helper_Data::XML_PATH_GENERAL_ACTIVE, 1);
Mage::getConfig()->cleanCache();
@aleron75
aleron75 / load_media_gallery
Created May 19, 2015 10:26
Load Magento product media gallery