Skip to content

Instantly share code, notes, and snippets.

View magefast's full-sized avatar
🥶

Alex S magefast

🥶
View GitHub Profile
@magefast
magefast / Magento - get all categories with filter is-active
Created January 31, 2019 16:56
Magento - get all categories with filter is-active
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('time_limit', 180);
set_time_limit(180);
require_once dirname(__FILE__) . '/app/Mage.php';
$app = Mage::app('admin');
umask(0);
$categories = Mage::getModel('catalog/category')
@magefast
magefast / Magento - unassign categories of product
Created January 24, 2019 22:10
Magento - unassign categories of product
<pre>
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('max_execution_time', 1000);
require_once dirname(__FILE__) . './../app/Mage.php';
Mage::app('default');
$file = 'file_no_categories_product.csv';
$csv = new Varien_File_Csv();
$data = $csv->getData($file);
@magefast
magefast / for merge translate from 2 to 1
Created January 14, 2019 21:49
Magento 2, translate merge. Get untranslated phrases.
<pre>
<?php
$row = 1;
if (($handle = fopen('other_translate.csv', "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
$row++;
$arrayTempMMM[] = array('original'=>$data[0],'translate'=>$data[1]);
@magefast
magefast / Magento - remove all images of products
Last active January 31, 2019 17:50
Magento - remove all images of products
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('time_limit', 180);
set_time_limit(180);
require_once dirname(__FILE__) . './../app/Mage.php';
$app = Mage::app('admin');
umask(0);
@magefast
magefast / get data by SKU (Old Magento) - cat_by_sku.php
Last active December 19, 2018 09:03
Copy category of product (or other data) from Current Magento and Old Magento (restored backup)
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once './app/Mage.php';
$data = array();
/**
* Check SKU param
*/
if (Mage::app()->getRequest()->getParam('sku')) {
@magefast
magefast / Magento, remove images dublicat
Created October 25, 2018 08:59
Magento, remove images dublicat
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once './app/Mage.php';
Mage::app();
$collection = Mage::getModel('catalog/product')->getCollection();
$productImg = array();
$ii = 0;
@magefast
magefast / rm-image-small_image-thumb of product
Created September 23, 2018 07:54
rm-image-small_image-thumb of product if not exist file
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once './app/Mage.php';
Mage::app();
$collection = Mage::getModel('catalog/product')->getCollection();
$productImg = array();
@magefast
magefast / create_attributes.php
Created June 12, 2018 14:16 — forked from nklatt/create_attributes.php
Programmatically add new product attribute with options to a Magento 2 store and add to Default attribute group
<?php
defined('STDIN') or die(_("Access Denied. CLI Only"));
// execute from the command line: php <path to magento root>/cli/create_attributes.php
require __DIR__.'/../app/bootstrap.php'; // assuming this file is in /cli under the root magento dir
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$installer = $bootstrap->getObjectManager()->create('Magento\Catalog\Setup\CategorySetup');
$objectManager = $bootstrap->getObjectManager();
@magefast
magefast / exportcat.php
Created May 8, 2018 05:47
Magento - export category data for SEO
<pre>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once './app/Mage.php';
$app = Mage::app();
@magefast
magefast / CSV for import via Admin panel
Created April 28, 2018 04:24
Megento - Set Products to Archive, unset categories
sku,visibility,qty,_category,stock_availability
253116,5,0,,0