Cron job has not been configured yet

Installation extension error

PS D:\xampp\htdocs\magento2> php bin/magento setup:cron:run
#!/usr/bin/env php
setup-cron: Please check var/log/update.log for execution summary.

You can see
setup-cron.ERROR: Your current PHP memory limit is 328M. Magento 2 requires it to be set to 756M or more. As a user with root privileges, edit your php.ini file to increase memory_limit.

See if the following file exists:
Magento install dir/var/.setup_cronjob_status
If the file exists, cron has run successfully in the past.

magento-directory/setup/src/Magento/Setup/Controller/Environment.php

commented out :
//$setupCheck = $this->cronScriptReadinessCheck->checkSetup();
//$updaterCheck = $this->cronScriptReadinessCheck->checkUpdater();

and replaced it with :
$setupCheck = ['success' => 1];
$updaterCheck = ['success' => 1];

Advertisements

Magento2 Snippets

|| Call phtml file in static block or cms page

   custom file path(Based on your theme you can change it)
   app/design/frontend/{Vendor}/{theme}/Magento_Theme/templates/html/test.phtml

   calling in xml layout file
   <block class="Magento\Framework\View\Element\Template" name="test_file" template="Magento_Theme::html/test.phtml"/>

   calling in blocks and cms pages
   {{block class="Magento\Framework\View\Element\Template" name="test_file" template="Magento_Theme::html/test.phtml"}}

   calling in any phtml file
   <?php include ($block->getTemplateFile('Magento_Theme::html/test.phtml')) ?>

   OR
   as before 
   <?php echo $this->getLayout()->createBlock("Magento\Framework\View\Element\Template")->setTemplate("Magento_Theme::html/test.phtml")->toHtml();?>


Basic Javascript

// multiple loop
for(i = 0, j = 10; i<=10, j>=0; i++, j--){
    console.log(i, j);
}


// factorial 1-10
var factorial = 1;
for(n = 1; n <= 10; n++){
    factorial *= n;
    console.log("factorial of ", n , "is ", factorial);
}


// Number series 

// s1 = 2 4 6 8 10 12 14 ...
var series = "";
var n;
for(i = 0; i < 10; i++){
    n = i*2;
    series = series + n + " "; 
}
console.log("Series One = " + series);



// s2 = 1 4 7 10 13 16 ...
var series = "";
var n = 1;
for(i = 0; i < 10; i++){
    n = n + 3;
    series = series + n + " "; 
}
console.log("Series Two = " + series);



// s3 = 0 3 8 15 24 35 45 ...
var series = "";
var n;
for(i = 1; i < 10; i++){
    n = i*i-1;
    series = series + n + " "; 
}
console.log("Series Three = " + series);



// s4 = 1 4 3 8 5 12 7 16 ....
var series = "";
for(i = 1; i < 10; i++){
    n = i;
    if(n%2 == 0){
        n = n*2;
    }
    series = series + n + " ";
}
console.log("Series Four = " + series);



// s5 = 0 1 1 2 3 5 8 13 ... fibonacci
var series = "0 1 ";
var x = 0;
var y = 1;
for(i = 0; i < 10; i++){
    n = x+y;
    x = y;
    y = n; 

    series = series + n + " ";
}
console.log("Series Four = " + series);



// divisors
var n = 148;
var range = Math.ceil(Math.sqrt(n));
var divisors = "";

for(i=0; i<=range; i++){
    if(n%i == 0){
        if(i == n/i){
            divisors += i + " ";
        }else{
            divisors += i + " " + (n/i) + " ";
        }    
    }
}
console.log(divisors);



// Calendar
var monthName = "May";
var days = 31;
var startingday = 2;

console.log("Calendar of ",monthName,"\n");
console.log("Sun   Mon   Tue   Wed   Thu   Fri   Sat");

for(var i=0; i<5; i++){
    var dayRow = "";
    for(var j=1; j<=7; j++){
        var currentDay = 7*i + j - startingday;
        
        if(currentDay>days){
            break;
        }else if(currentDay<1){
            currentDay = " ";
        }

        if(currentDay>9){
            dayRow += currentDay + "    ";
        }else{
            dayRow += currentDay + "     ";
        } 

    }
    console.log(dayRow);
}



//Array
var fruits = ["Apple","Banana","Orange","Date","Grape"];
console.log(fruits[0]);


// last element
var lastIndex = fruits.length-1;
console.log(fruits[lastIndex]);


// slice, splice
var list = [
    "sun", //0 = -7
    "mon", //1 = -6
    "tue", //2 = -5
    "wed", //3 = -4
    "thu", //4 = -3
    "fri", //5 = -2
    "sat"  //6 = -1
];

var chunk = list.slice(1, 4);
console.log(list,chunk);
console.log("\n");

var chunk = list.splice(1, 4);
console.log(list,chunk);



// deep copy
var list = [
    "sun", //0 = -7
    "mon", //1 = -6
    "tue", //2 = -5
    "wed", //3 = -4
    "thu", //4 = -3
    "fri", //5 = -2
    "sat"  //6 = -1
];

var list2 = list;
list2[2] = "No Day";
console.log(list2, list);



// shallow copy
var v1 = 1;
var v2 = v1;
v2 = 2;
console.log(v1,v2);


// array merge
var list1 = ["sun","mon","tue"];
var list2 = ["wed","thu","Fri"];

var list = list1.concat(list2);
console.log(list);


Create an Admin theme

1.Create Admin theme directory
In the app/design/adminhtml directory create a new <Vendor>/<admin_theme> directory.

2.Add a declaration theme.xml
Add or copy from an existing theme.xml to your theme directory app/design/adminhtml/Vendor/<admin_theme>

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
	<title>Ataur Admin</title> <!-- your theme's name -->
	<parent>Magento/backend</parent> <!-- the parent theme. Example: Magento/backend -->
</theme>	

3.Add registration.php
In your theme directory app/design/adminhtml/<Vendor>/<admin_theme> create a registration.php file.

<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
\Magento\Framework\Component\ComponentRegistrar::register(
	\Magento\Framework\Component\ComponentRegistrar::THEME,
	'adminhtml/Ataur/my-first-admin-theme', // Example: 'adminhtml/Magento/backend'
	__DIR__
); 

4.Admin theme logo
In the default Magento/backend theme lib/web/images/magento-logo.svg is used as theme logo. To override it, in your theme directory, create a web/images sub-directory, and add your custom file named magento-logo.svg

5.Apply an Admin theme
Prerequisites:
1.Set your Magento application to the developer mode.
2.Create a custom theme for the Admin panel.
3.Add a new custom module or decide to use existing custom module. The module must load after the Magento_Theme module. To ensure this, add the following code app/code/[VendorName]/[ModuleName]/etc/module.xml

(replace placeholders with your module information):

<module name="Ataur_Override" setup_version="2.0.1"> <!-- Example: "Magento_Backend -->"
	<sequence>
		<module name="Magento_Theme"/>
	</sequence>
</module>

6.Specify the custom Admin theme in di.xml
You need to specify the admin theme to be used in the <your_module_dir>/etc/di.xml file. Add it, if the file does not yet exist in your module.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
	<!-- Admin theme. Start -->
	<type name="Magento\Theme\Model\View\Design">
		<arguments>
			 <argument name="themes" xsi:type="array">
				 <item name="adminhtml" xsi:type="string">Ataur/my-first-admin-theme</item> <!-- Example: "Magento/backend" -->
			 </argument>
		 </arguments> 
	</type>
	<!-- Admin theme. End -->
</config>

7.Update components to actually apply the Admin theme
For your changes to take effect, you need to update Magento components. For this,
run the php bin/magento setup:upgrade command in your command line. If prompted, also run
php bin/magento setup:di:compile

error face: Controller preference not working after setup:di:compile
solution: Have you tried to run php bin/magento setup:static-content:deploy afterwards?
And just in case, run again php bin/magento setup:upgrade at the very end of operations.

Magento2 Installation

Magento2 download by composer

1.You have to setup composer in your htdocs
2.Must be check magento prerequisites
3.Go to magento documentation and find on the left side Getting Started > Install Magento using Composer
3.Select which version is compatibility with your php
4.Avoiding so many problem just change from D:\xampp\php\php.ini

memory_limit=328M
max_input_time=300
max_execution_time=18000

extension=php_intl.dll
extension=php_soap.dll
extension=php_xsl.dll

5.Enter the following command. Obviously copy this code from Magento Open Source metapackage. Fact of (version)

php composer.phar create-project –repository-url=https://repo.magento.com/ magento/project-community-edition <installation directory name>

Version specify:
php composer.phar create-project –repository-url=https://repo.magento.com/ magento/project-community-edition=2.1.7 /installation/directory name

or

composer create-project –repository-url=https://repo.magento.com/ magento/project-community-edition <installation directory name>

6.When prompted, enter your authentication keys from your magento profile.
Your public key is your username.
your private key is your password.

7.Now you can see it’s downloading so many files. After few minutes Successfully you can see
Generating autoload files

Magento2 install by command line

D:\xampp\htdocs\magento2> composer
D:\xampp\htdocs\magento2> composer install
D:\xampp\htdocs\magento2> php bin/magento setup:install

php bin/magento setup:install –base-url=http://127.0.0.1/magento2/ –db-host=localhost –db-name=test-magento2 –db-user=root –db-password= –admin-firstname=Ataur –admin-lastname=Rahman –admin-email=appointbd@gmail.com –admin-user=webTech –admin-password=webTech1234@ –language=en_US –currency=USD –timezone=America/Chicago –use-rewrites=1

Magento 2 CLI

php bin/magento help
php bin/magento list
php bin/magento indexer:reindex
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento cache:disable
php bin/magento cache:enable
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy

[doest not generate files in the pub/static folder. Try to run below command]
php bin/magento setup:static-content:deploy -f

Set the Magento mode

Developer mode:
You should use the Developer mode while you are developing customizations or extensions

php bin/magento deploy:mode:show
php bin/magento deploy:mode:set developer

Production mode:
You should run Magento in Production mode once it is deployed to a production server. Production mode provides the highest performance in Magento 2.

Install sample data after Magento

Do not install sample data if your Magento application is set for production mode. Switch to developer mode first. Installing sample data in production mode fails.

php bin/magento sampledata:deploy

If you’re installing sample data after installing Magento, you must also run the following command to update the database and schema:

php bin/magento setup:upgrade