Skip to content

Instantly share code, notes, and snippets.

View pusachev's full-sized avatar
🏄‍♂️
Surf

Pavlo Usachov pusachev

🏄‍♂️
Surf
View GitHub Profile
#!/bin/bash
if [ "$MAGENTO_VERSION" != false ]
then
composer create-project --repository=https://repo.magento.com/ magento/project-community-edition:${MAGENTO_VERSION} .
else
composer create-project --repository=https://repo.magento.com/ magento/project-community-edition .
fi
mkdir -p ./var/composer_home/
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .
php -dmemory_limit=-1 bin/magento setup:install --base-url=http://127.0.0.1/magento2/ --db-host=localhost --db-name=magento --db-user=magento --db-password=magento --admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com --admin-user=admin --admin-password=admin123 --language=en_US
php -dmemory_limit=-1 bin/magento sampledata:deploy && php -dmemory_limit=-1 bin/magento setup:upgrade
@pusachev
pusachev / gist:e33a714fca53dc27875b3c896aa0feb9
Created April 24, 2018 14:43
Magento2 get min || max price from collection
/** @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $collectionFactory */
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */
$collection = $this->collectionFactory->create();
$collection->addAttributeToSelect('price');
$collection->setOrder('price', 'DESC');
$category = $this->registry->registry('current_category');
if (!($category instanceof \Magento\Catalog\Model\Category)) {
@pusachev
pusachev / createBundleProduct.php
Last active March 15, 2021 14:50
Magento2 Create Bundle Product with option
/** @var $productFactory \Magento\Catalog\Api\Data\ProductInterfaceFactory */
/** @var $product \Magento\Catalog\Api\Data\ProductInterface */
$product = $this->productFactory->create();
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE);
$product->setStatus(1);
$product->setVisibility(4);
$product->setCustomAttribute('tax_class_id', 0); // 0 - tax class none, 1
$product->setCustomAttribute('website_ids', [1]); // 1 - default website
alias ubuntu-full-update="sudo apt update -y && sudo apt upgrade -y && sudo apt autoremove -y"
alias docker-exec-php="docker exec -it devbox-php-fpm-1 sh"
alias docker-redis-clean="docker exec -it devbox-redis-1 redis-cli flushall"
alias docker-inspect-php="docker inspect devbox-php-fpm-1"
alias docker-kill-all="docker kill $(docker ps -aq)"
alias docker-stop-all="docker container stop $(docker container ls -aq)"
alias docker-rm-containers="docker container rm $(docker container ls -aq)"
alias docker-rm-images="docker rmi -f $(docker images -aq)"
alias docker-remove-all="docker rm $(docker ps -a -q)"
alias connect-ovpn-arc="sudo openvpn --config ~/Documents/openvpn.ovpn --daemon"
-- For table users, CREATE TABLE `users` (id int not null, name text);
--Without repeats
SELECT `id` FROM `users` GROUP BY `id` HAVING count(*)>1;
--With repeats
SELECT `id` FROM `users` WHERE `id` IN (SELECT `id` FROM `users` GROUP BY `id` HAVING count(*)>1);
{
"name": "Magento grunt tasks",
"version": "1.0.0",
"sp_simpleslider": "0.1.0",
"description": "",
"main": "Gruntfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Pavel Usachev",
/**
* @author Pavel Usachev <webcodekeeper@hotmail.com>
* @copyright Copyright (c) 2017, Pavel Usachev
*/
'use strict';
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
#mod_macro https://www.cri.ensmp.fr/~coelho/mod_macro/
<Macro VHostDev $baseDomain>
<VirtualHost *:80>
ServerName $baseDomain.dev
ServerAlias www.$baseDomain.dev
# Module mpm-itk
AssignUserID alexandr alexandr
DocumentRoot /home/alexandr/projects/dev/application/$baseDomain/web
zend_extension=xdebug.so
xdebug.idekey = PHPSTORM
xdebug.remote_enable=1
xdebug.remote_host="127.0.0.1"
xdebug.remote_port=9001
xdebug.remote_autostart=0
xdebug.remote_handler="dbgp"
xdebug.remote_mode="req"
xdebug.remote_connect_back=0