Skip to content

Instantly share code, notes, and snippets.

View manojchowrasiya's full-sized avatar

manojchowrasiya

View GitHub Profile
@manojchowrasiya
manojchowrasiya / magento.md
Last active April 27, 2018 18:57 — forked from manojiksula/magento.md
Magento 1x Code Snippet

Data to CSV

 public function exportOrders($orders) 
    {
        $fileName = 'order_export_'.date("Ymd_His").'.csv';
        $fp = fopen(Mage::getBaseDir('export').'/'.$fileName, 'w');

        $this->writeHeadRow($fp);
        foreach ($orders as $order) {
 $this->writeOrder($order, $fp);
@manojchowrasiya
manojchowrasiya / gitworkflow.txt
Created October 13, 2017 07:41 — forked from seamusjr/gitworkflow.txt
Simple git workflow
# Git workflow example.
# Inspired by http://nakedstartup.com/2010/04/simple-daily-git-workflow
# Create a local working branch
# You only need to do when you want to create
# a local working branch for your project
#
# I use the convention feat_project_name so it can be feat_puma
git checkout -b branch_name_here
@manojchowrasiya
manojchowrasiya / config.json
Created April 13, 2017 09:58 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
@manojchowrasiya
manojchowrasiya / Proposal.md
Created April 6, 2017 13:59 — forked from IvanChepurnyi/Proposal.md
Architectural Proposal for Magento 2 Inventory and Prices Mechanism

Problem

There are too tight relations of stock and prices to store views and websites in Magento that results in high complexity of implementation of b2b and drop shipping solutions in Magento.

The issue was very visible with the price index structure for Magento 1, and now Magento 2 stock index follows the same idea of having an index entry per website.

This strict relation to a website makes unnecessary data duplications in case if you have global stock. Although it makes over complicated multi-warehouse delivery, as you will be required to create a separate website for each warehouse, that duplicates other product data in the flat index structure and price index.

Solution

Create a separate scope entity for Price and Inventory, for using them as scope fields for respective data structures.

@manojchowrasiya
manojchowrasiya / gist:463924a075e5fb4ac4b909d7db7fafbb
Created March 20, 2017 10:07 — forked from ThomasBurleson/gist:2432692
AngularJS - RESTful CRUD with Services and $http
//
// CRUD API for RESTful services with URLs similar 'http://services.mysite.com/classes/Book'.
//
// e.g. parse.get(
// "Book",
// 123,
// function(response){ console.log(response.toString());}
// );
//
services.factory('parse', function($rootScope, $http) {
@manojchowrasiya
manojchowrasiya / gist:f458d781ed74a03a9eaaeaf04094f745
Created February 1, 2017 10:44 — forked from jmertic/gist:6584335
Exporting a report as a PDF using the new RESTful API in Sugar 6.7 and later.
<?php
// specify the REST web service to interact with
$url = 'https://localhost/~jmertic/sugar7/ent/sugarcrm/rest/v10';
// And admin username/password
$username = 'will';
$password = 'will';
// And the report_id you wish to export
@manojchowrasiya
manojchowrasiya / Magmi Settings
Created January 13, 2017 06:11 — forked from kontikidigital/Magmi Settings
Magento: Magmi Setting
Visibility
The way to go for column “visibility” is as follows:
1 = Not Visible Individually
2 = Catalog
3 = Search
4 = Catalog, Search
Delete Products
Activate Magmi Deleter Plugin
"sku","magmi:delete"
@manojchowrasiya
manojchowrasiya / cart_price_rule_1_steps.txt
Created January 13, 2017 06:08 — forked from herveguetin/cart_price_rule_1_steps.txt
Programmatically create a cart price rule in Magento
This is a quick an easy hack to programmatically create a cart price rule.
1. Temporarely edit Mage_Adminhtml_Promo_QuoteController::saveAction()
2. Around line 123, you will find $data = $this->getRequest()->getPost();
3. Below this line create a new line containing :
var_export($data);
die();
@manojchowrasiya
manojchowrasiya / next_business_day.php
Created January 13, 2017 06:08 — forked from herveguetin/next_business_day.php
Retrieve the next business or calendar day in Magento with an optional leadtime. Magento weekend days config is taken into account.
<?php
/**
* Retrieve the next business day with an optional leadtime.
* If leadtime = 1 => find the next business day
* If leadtime = 2 => find the "next next" business day
* etc...
*
* @param int $leadtime
* @return string|bool
*/
<?php
$customerGroupId = SOME_CUSTOMER_GROUP_ID;
$table = Mage::getModel('customer/customer')->getResource()
->getWriteConnection()
->getTable('customer/entity');
$query = "UPDATE {$table} SET group_id = {$customerGroupId} WHERE group_id != {$customerGroupId}";
$conn->query($query);
?>