Skip to content

Instantly share code, notes, and snippets.

@obukhow
obukhow / simple_not_visible.sql
Last active August 29, 2015 14:12
Make simple products of configurable not visible
update
`catalog_product_entity_int`
set
`value` = 1
where
`attribute_id`=(select `attribute_id` from `eav_attribute` where `attribute_code` = 'visibility')
and
`entity_id` in (select `product_id` from `catalog_product_super_link`);
@obukhow
obukhow / convert.md
Last active March 2, 2016 16:59
Change Magento Product Images File Type

For inctance, we need to convert all .gif to .jpg

Execute next commands in teminal

> cd /vaw/www/media/catalog/product/
> for i in $(find $(pwd) -name \*.gif -print); do convert $i $(echo $i.jpg | sed s/.gif//g); done
> rm -r cache/

Then, run these sql-statements in DB

@obukhow
obukhow / russian_regions.sql
Last active August 29, 2015 14:06
Magento add Russian Regions
INSERT INTO `directory_country_region` (`region_id`,`country_id`,`code`,`default_name`) VALUES
(Null,'RU','RU-AD','Республика Адыгея (Адыгея)'),
(Null,'RU','RU-BA','Республика Башкортостан'),
(Null,'RU','RU-BU','Республика Бурятия'),
(Null,'RU','RU-AL','Республика Алтай'),
(Null,'RU','RU-DA','Республика Дагестан'),
(Null,'RU','RU-IN','Республика Ингушетия'),
(Null,'RU','RU-KB','Кабардино-Балкарская Республика'),
(Null,'RU','RU-KL','Республика Калмыкия'),
(Null,'RU','RU-KC','Карачаево-Черкесская Республика'),
@obukhow
obukhow / update.php
Last active January 29, 2016 11:15
Magento update text attribute type to select
<?php
require "app/Mage.php";
umask(0);
Mage::init('admin', 'store');
$attrCode = 'model'; //your attribute code here
$attrId = (int) Mage::getModel('eav/entity_attribute')->getIdByCode(Mage_Catalog_Model_Product::ENTITY, $attrCode);
$resource = Mage::getSingleton('core/resource')->getConnection('core_write');
try {
<?php
public function getPlaceInArray(&$array, &$ri, &$rj, $di = 1, $dj = 1, $t = null)
{
$ri = 0;
$rj = 0;
while (1) {
$ri = rand(0, Mage::getStoreConfig('project/config/lines') - $di);
$rj = rand(0, Mage::getStoreConfig('project/config/columns') - $dj);
@obukhow
obukhow / gist:5040981
Created February 26, 2013 18:48
Magento file size and file extensions frontend validation
Validation.addAllThese([
['validate-filesize','The file size should not exceed 100 kb.',function(v, elm){
var maxSize = 102400;
if (navigator.appName == "Microsoft Internet Explorer") {
if (elm.value) {
var oas = new ActiveXObject("Scripting.FileSystemObject");
var e = oas.getFile(elm.value);
var size = e.size;
}
} else {