This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Using a key => value pair with the yield keyword is | |
* the cleanest method I could find to add identifiers or tags | |
* to asynchronous concurrent requests in Guzzle, | |
* so you can identify which response is from which request! | |
*/ | |
$client = new GuzzleHttp\Client(['base_uri' => 'http://httpbin.org']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 1. Register the routes | |
Route::get('test/{lorem}', function ($lorem) { | |
sleep(3); | |
return response()->json([ | |
'message' => $lorem, | |
'token' => Str::random(), | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Don't forget that in order for profiler to work it has to be enabled, else you will get empty profiles. | |
*/ | |
$profiler = Mage::getSingleton('core/resource')->getConnection('core_write')->getProfiler(); | |
$queryProfiles = $profiler->getQueryProfiles(); | |
$profiles = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'app/Mage.php'; | |
Mage::app(); | |
$attributeSetName = 'Electric scooters'; // Name of the attribute set | |
//$groupName = 'Frontend'; | |
$code = 'my_attribute_code'; | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$productCollection->getSelect()->join( | |
new Zend_Db_Expr("(SELECT product_id, SUM(impressions) as impressions, SUM(clicks) as clicks, SUM(cart) as cart, SUM(conversions) as conversions, round(SUM(profit), 2) as profit, round(SUM(profit)/SUM(impressions), 3) as rpi | |
FROM evermart_crosssells_statistics_daily" . | |
($dateFilter ? " WHERE $dateFilter" : "") | |
. " GROUP BY product_id)"), | |
't.product_id = e.entity_id', | |
array('t.impressions','t.clicks', 't.cart', 't.conversions', 't.profit', 't.rpi') | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER TABLE `table_name` | |
ADD `updated_at` datetime NULL DEFAULT now() on update now(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sortTable(table, col, reverse) { | |
var tb = table.tBodies[0], | |
tr = Array.prototype.slice.call(tb.rows, 0), | |
i; | |
reverse = -((+reverse) || -1); | |
tr = tr.sort(function (a, b) { | |
return reverse | |
* (a.cells[col].textContent.trim() | |
.localeCompare(b.cells[col].textContent.trim()) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
date_default_timezone_set(Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE)); | |
$currentShopTime = date('Y-m-d H:i:s'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$product = Mage::getModel('catalog/product') | |
->load(11925); | |
$children = $product->getTypeInstance()->getUsedProducts($product); | |
$children_ids = []; | |
foreach ($children as $child){ | |
$children_ids[] = $child->getID(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$product = Mage::getModel('catalog/product') | |
->load(9275); | |
$collection = $product->getTypeInstance(true) | |
->getSelectionsCollection($product->getTypeInstance(true)->getOptionsIds($product), $product); | |
$children_ids = []; |
NewerOlder