Skip to content

Instantly share code, notes, and snippets.

View mcjwsk's full-sized avatar

Dariusz Maciejewski mcjwsk

View GitHub Profile
<?php
$langs = array(
0 => '1 produkt',
1 => '%d produkty',
2 => '%d produktów',
);
$n = 9;
$plural = (($n==1)?(0):((((($n%10)>=2)&&(($n%10)<=4))&&((($n%100)<10)||(($n%100)>=20)))?(1):2));
@mcjwsk
mcjwsk / eav.md
Last active August 25, 2015 19:43
+---------------------------------------------+
| Tables_in_mage                              |
+---------------------------------------------+
| admin_assert                                |
| admin_role                                  |
| admin_rule                                  |
| admin_user                                  |
| adminnotification_inbox                     |
| api2_acl_attribute                          |
@mcjwsk
mcjwsk / reset.php
Last active September 25, 2015 08:16
<?php
require 'app/Mage.php';
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
// Reset admin path.
$config = Mage::getSingleton('core/config');
$config->saveConfig('admin/url/custom_path', 'admin', 'default', 0);
$config->saveConfig('web/unsecure/base_url', '{{base_url}}', 'default', 0);
$config->saveConfig('web/secure/base_url', '{{base_url}}', 'default', 0);
$config->saveConfig('web/cookie/cookie_domain', '', 'default', 0);
<?php
class SomeParent {
public function test() {
echo 'parent';
}
}
class Element1 extends SomeParent {
public function test() {
diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php
index 6c815ed68827dded619ecac227eda53ec860abf6..aa8e7d3812d7179fc254b47cbacbf89295a8a3f0 100644
--- a/app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php
+++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/Abstract.php
@@ -278,13 +278,17 @@ abstract class Mage_ImportExport_Model_Import_Entity_Abstract
$this->_dataSourceModel->cleanBunches();
while ($source->valid() || $bunchRows) {
+ //if the row scope isn't default we aren't finished with this entity
+ if ($startNewBunch && $source->valid() && !$this->_isRowScopeDefault($source->current())) {
@mcjwsk
mcjwsk / Data.php
Created December 23, 2015 11:51
math helper to sum fractions
<?php
class Snowdog_Math_Helper_Data extends Mage_Core_Helper_Abstract
{
/**
* Greatest common divisor using Euclid's algorithm
*
* @param int $a
* @param int $b
* @return int
<?php
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__));
$invalidFiles = array();
foreach ($files as $file) {
if ($file->isLink() || $file->isDir()) {
continue;
}
$fileName = $file->getFilename();
if ($fileName == 'config.xml') {
@mcjwsk
mcjwsk / clearlogs.sql
Last active April 22, 2021 20:57
magento
TRUNCATE dataflow_batch_export;
TRUNCATE dataflow_batch_import;
TRUNCATE log_customer;
TRUNCATE log_quote;
TRUNCATE log_summary;
TRUNCATE log_summary_type;
TRUNCATE log_url;
TRUNCATE log_url_info;
TRUNCATE log_visitor;
TRUNCATE log_visitor_info;
UPDATE customer_entity SET email = REPLACE(email, '@', '-test@abcxyz123-');
UPDATE sales_flat_order SET customer_email = REPLACE(customer_email, '@', '-test@abcxyz123-');
UPDATE sales_flat_order_address SET email = REPLACE(email, '@', '-test@abcxyz123-');
UPDATE sales_flat_order_grid SET customer_email = REPLACE(customer_email, '@', '-test@abcxyz123-');
alias ll='ls -l'
alias json='python -mjson.tool'