Skip to content

Instantly share code, notes, and snippets.

@trushang541
trushang541 / m2_script_url_rewrite.php
Created February 15, 2018 12:00
Magento 2 add url rewrite links using script
<?php
use Magento\Framework\App\Bootstrap;
use Magento\Customer\Api\AccountManagementInterface;
use Magento\Customer\Model\AccountManagement;
require __DIR__ . '/../app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
@trushang541
trushang541 / gist:6a0e1f9db147adc5e912ec1adc15fa94
Created March 16, 2017 11:05
clear magento cache programatically
<?php
include $_SERVER['DOCUMENT_ROOT'].'/app/Mage.php';
Mage::app('default');
/**
clear magento cache programatically
*/
function clean_magento_cache(){
Mage::app()->getCache()->clean();
@trushang541
trushang541 / gist:e6026406562b5b88a09863c1850f28dc
Created March 10, 2017 07:24
Magento Get Product List using category id
protected function getProductbyCategory() {
$categoryId=3;
$category = Mage::getModel('catalog/category')->load($categoryId);
$prodCollection = Mage::getResourceModel('catalog/product_collection')
->addCategoryFilter($category)
->addAttributeToSelect('*');
foreach ($prodCollection as $val) {