Skip to content

Instantly share code, notes, and snippets.

View Bat-Chat's full-sized avatar

Vladyslav Shestopalov Bat-Chat

View GitHub Profile
echo ceil((7/0)*100); // Warning: Division by zero
echo "\n\n";
echo "no Warning:) \n", ceil(@(7/0)*100);
@Bat-Chat
Bat-Chat / zendDate
Last active May 22, 2018 22:16
# time in magento
$zendDate = Mage::app()->getLocale()->date();
$zendDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$zendDate->sub('30',Zend_Date::MINUTE_SHORT)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
@Bat-Chat
Bat-Chat / query by native sql
Created July 30, 2016 23:04
запись в базу нативным sql-ом
запись в базу нативным sql-ом
$writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
$table = $resource->getTableName('catalog/product');
$currentTime = date('Y-m-d H:i:s', time());
$query = "UPDATE {$table} SET column = column + 1 WHERE updated_at = {$currentTime}";
$writeConnection->query($query);
@Bat-Chat
Bat-Chat / Add tag in git
Created July 30, 2016 22:26
Add tag and push it to stage
git fetch --tags
git tag
git tag -a v1.0.52 -m 'Commit description'
git push origin v1.0.52
then on stage repository:
git branch stage
git pull origin stage
then change composer.json (set new version for package)
@Bat-Chat
Bat-Chat / gist:fe6275e2776c0aa9536f0b2815121b2e
Last active July 30, 2016 21:44
Chose shop in index.php
$mageRunCode = 'shopAlias';
@Bat-Chat
Bat-Chat / local.xml
Created July 12, 2016 11:31
Add this file for printing errors in magento (src/errors/local.xml)
<?xml version="1.0"?>
<!--
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
@Bat-Chat
Bat-Chat / overriding old tag
Created July 11, 2016 15:07
overriding old tag (move tag to latest commit)
Use the -f option to git tag:
-f
--force
Replace an existing tag with the given name (instead of failing)
You probably want to use -f in conjunction with -a to force-create an annotated tag instead of a non-annotated one.
Example
@Bat-Chat
Bat-Chat / gist:a6e967bac4a39c6d5e4cdd9424dd1c02
Last active July 30, 2016 22:07
Get order_payment collection (like)
$conditions = array();
$words = preg_split( "/([ ]+|[-]+|[_]+)/", $value);
foreach( $words as $value ){
$conditions[] = array('like' => "%{$value}%");
}
$paymentTableName = Mage::getSingleton('core/resource')->getTableName('sales/order_payment');
$this->getCollection()->addFieldToFilter(
"{$paymentTableName}.method",
array('like' => "%{$value}%")
@Bat-Chat
Bat-Chat / questionMarkInString
Created March 16, 2016 11:28
Когда строка состоит из кириллицы и utf-8 могут отображаться символы - "�". Для вывода или замены строки из кириллицы делать следиущее:
$name = 'Кириллица вместе с utf-8';
$name = iconv("windows-1251", "utf-8", $name);
$name = str_replace('Кириллица', '', $name);
$fileHeaders = @get_headers($imgUrl);
if($fileHeaders[0] == 'HTTP/1.1 200 OK') {
echo 'image exists';
}