Skip to content

Instantly share code, notes, and snippets.

@tieutantan
Forked from JeansBolong/Magento2.md
Created September 12, 2018 10:41
Show Gist options
  • Save tieutantan/3a140b1773e4649a43b5791bb6e2972d to your computer and use it in GitHub Desktop.
Save tieutantan/3a140b1773e4649a43b5791bb6e2972d to your computer and use it in GitHub Desktop.
Magento2 CheatSheet

Magento 2 tutorial

http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/bk-frontend-dev-guide.html
https://www.creare.co.uk/blog/magento/theming-in-magento-2-part-1
https://www.creare.co.uk/blog/magento/theming-in-magento-2-part-2
http://alanstorm.com/category/magento-2/

I have installed Magento 2 successfully, but icons are not displaying and not able to click anywhere in backend.

Please try running following command.

php bin/magento deploy:mode:set developer
php bin/magento setup:static-content:deploy
php bin/magento setup:static-content:deploy --theme=Vendor/mytheme
php bin/magento setup:static-content:deploy --exclude=Magento/luma,Magento/blank
php bin/magento setup:upgrade

How can I check magento module status?

php bin/magento module:status

How can I clear Cache and Reindex?

Here are the commands to cache and reindex.

php bin/magento cache:disable
php bin/magento cache:status
php bin/magento cache:flush
php bin/magento cache:clean
php bin/magento indexer:reindex

How can I de compile using command?

Try running this command for de compile.

php bin/magento setup:di:compile

Turn template hints on/off

UPDATE
`core_config_data`
SET
`value` = 1
WHERE
`path` = "dev/debug/template_hints_storefront"

add js file via require.js

  1. Create file requirejs-config.js at app/design/[vendor]/[theme]/ with this content
var config = {

    // When load 'requirejs' always load the following files also
    deps: [
        "js/wim" //js file yang akan di load simpan di app/design/[vendor]/[theme]/web/js
    ]

};

magento new js file example to load other js lib

  1. Create other.js file at app/design/[vendor]/[theme]/web/js/
define([
    'underscore',
    'jquery'
], function(){
    "use strict";

    _.each(["Hello", "World", "!!!!!!!!!!!!!!!!!!" ], console.log);


});

Grunt

grunt exec:<your_theme>
grunt less:<your_theme>
grunt watch

Less breakpoint variable

  @screen__xxs: 320px;
  @screen__xs: 480px;
  @screen__s: 640px;
  @screen__m: 768px;
  @screen__l: 1024px;
  @screen__xl: 1440px;

add some container at xml layout

<container name="header.menu.wrapper" htmlClass="menu-wrapper" htmlTag="div" after="header.panel.wrapper2"><!-- parent container -->
	<container name="some.container" as="someContainer" label="Some Container" htmlTag="div" htmlClass="some-container"><!-- new container -->
		<block class="Magento\Framework\View\Element\Template" name="dropdown.menu" template="Magento_Theme::html/dropdown_nav.phtml" /> <!-- the content load from phtml -->
	</container>
</container> <!-- end of parent container -->

select core config magento for change base_url

SELECT path,VALUE FROM core_config_data WHERE path LIKE 'web/secure/base%';
SELECT path,VALUE FROM core_config_data WHERE path LIKE 'web/unsecure/base%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment