Skip to content

Instantly share code, notes, and snippets.

View jameshiggins's full-sized avatar
😍

James Higgins jameshiggins

😍
View GitHub Profile
<?php
include_once '../app/Mage.php';
Mage::app()->setCurrentStore( Mage_Core_Model_App::ADMIN_STORE_ID );
// Get the current page from $_GET
$curPage = intval(Mage::app()->getRequest()->getParam('page'));
$curPage = $curPage < 1 ? 1 : $curPage;
// Get all configurable and grouped products
$products = Mage::getModel('catalog/product')
I’ve seen recently this issue - editing and saving products in admin deleted existing images from frontend.
On evaluation it appeared that the images, while showing on the frontend, did not appear in the admin product edit Images tab at all.
Inspection of the database tables revealed that while EAV records contained image names (used on frontend), the image gallery (used in admin) was missing the relevant entries, so it appears that CSV import does not populate gallery table.
This problem will happen with both new and updated products, when new image names are added with CSV.
I’ve made an SQL statement that will fill the missing records, and which you will need to run each time after importing products with images using CSV:
INSERT INTO catalog_product_entity_media_gallery (attribute_id, entity_id, `value`)
SELECT ga.attribute_id, v.entity_id, v.value
FROM catalog_product_entity_varchar v
INNER JOIN eav_entity_type et ON et.entity_type_code='catalog_product'
SET FOREIGN_KEY_CHECKS = 0;
SET GROUP_CONCAT_MAX_LEN=32768;
SET @tables = NULL;
SELECT GROUP_CONCAT(table_name) INTO @tables
FROM information_schema.tables
WHERE table_schema = (SELECT DATABASE());
SELECT IFNULL(@tables,'dummy') INTO @tables;
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;
[alias]
# one-line log
l = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
a = add
ap = add -p
c = commit --verbose
ca = commit -a --verbose
cm = commit -m
cam = commit -a -m
@jameshiggins
jameshiggins / 0_reuse_code.js
Created June 13, 2014 06:57
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jameshiggins
jameshiggins / magento index.php
Last active August 29, 2015 14:02
Magento Index.PHP Error Reporting Active
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@jameshiggins
jameshiggins / index.php_better_maintenance_mode.php
Created June 12, 2014 18:27
Magento Index Better Maintenance Mode
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@jameshiggins
jameshiggins / gist:9a3606e393b18a44a7e4
Created June 12, 2014 18:25
Magento Permission Commands
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chown -R beautyse.beautyse beauty_test/