October 11, 2020

Magento2 deployment configuration is absent

[ Magento\Setup\Exception]

Can't run this operation: deployment configuration is absent. Run 'magento setup:config:set --help'  for options. setup:upgrade

Check app/etc/env.php is created

Also this message show because of 

app/etc/config.php is missing.

Check magento folder permission for app/etc


October 10, 2020

Magento2 - Change Catalog Search Engine

  1. Logon to Magento admin site.
  2. Navigate to Stores -> Configuration
  3. In left panel, find Catalog section
  4. In Catalog, Catalog -> Catalog Search
  5. In Search Engine choose the desired value from dropdown

 Then Save Configuration

Thanks


January 04, 2016

Javascript URL parse

Javascript URL parse

window.location.host : example.com:80
window.location.hostname : example.com
window.location.protocol : http:
window.location.port : 8080 or 80
window.location.origin : http://example.com *

January 13, 2015

MySQL storage engines

MySQL storage engines


MySQL storage engines
InnoDB
MyISAM
ISAM
MEMORY(HEAP)
BLACKHOLE


You want to know all storage engines. Login to mysql terminal window using mysql credentails
Just type the commane
show engines;
you get the list of all storage engines.

December 24, 2014

Magento how to call other block in phtml file

Magento how to call other block in phtml file

To get the block in your template, other than child block.
When you want to call the block other than specified xml child blocks.
$this->getLayout()->getBlock('block_name')->toHtml();
For example
$this->getLayout()->getBlock('top.links')->toHtml();    

December 20, 2014

Alternate to if else use switch statement


Alternate to if else use switch statement

If you execute the if else statements which multiple conditions
its go throw each condition and check with those condition is matching. For example you written if else condition
 
 if($i == 15)
 elseif($i == 25)
 elseif($i == 35)
 elseif($i == 45)
 elseif($i == 55)
 else
You want to match 45 value,while executing this above script variable matches with each if and else condition
and finally matches 45 value, so condition executed above with unmatched value then it took the execution time.

Alternative Switch statement

Suppose you are using the swithc statement for the above case. Example
 
 switch($i) {
   case 15:
     break;
   case 25:
     break;
   case 35:
     break;
   case 45:
     break;
   case 55:
     break;
 }
In this above switch statement, if the $i values was 45 then execute 45 matched values and go through the further process.

PHP error reporting


PHP error reporting

As of developer view, error reporting is more sensitive one.

There are 3 types of errors.
1) Fatal error
2) Warning error
3) Notice error

In production environment, we cant see the errors in live it appears blank page.
In this case, you want to see the server log normally for apache server which is generated in the server log file
/var/log/apache2/error.log

In terminal, you see the last few occurences error as
tail -f /var/log/apache2/error.log

While developing environment you want to see the all errors through
ini_set('display_errors', 1); /*By default its value as 0 in php.ini*/
error_reporting(-1); /*It shows all errors*/

Magento add Custom js/css in Current Theme

Add Custom JS/CSS in current theme


If you want the css and js for all the pages then you can add the code in local.xml with default handles xml tag.
 
   
     
       
         
       
       
         [css_filename.css]
       
     
   
 
[script_filename.js] - specify the script filename
[css_filename.css] - specify the css filename

For specific pages you want to add the custom css or js, then
specify the handles in local.xml and add the custom css, js xml code.

And also if want to add the custom css in specific handles,
then add the custom add code within that handles.

Modify Home Page Banner Image


Modify Banner Image


Step 1


Go to Magento admin pages through
Admin -> CMS -> Pages -> Edit home(Which mentioned in URL key)

Step 2


After click the home page which redirected to edit page.
In home edit page, go through the Content tab in left panel, click the tab.

Step 3


You see the textarea with the HTML code, in that you find the block id "home-slider".
You will change the home page banner images in the textarea.

Magento Product Collection Query


Magento product collection query

For developers, print the product collection query.

$statusEnabled = Mage_Catalog_Model_Product_Status::STATUS_ENABLED;

$collection = Mage::getModel('catalog/product')
                 ->getCollection()
                 ->addAttributeToFilter('status', 
                  $statusEnabled);
/**
 *
 * Print query
 *
 */
echo $collection->getSelect();
/**
 *or
 */
echo $collection->getSelect()->__toString();
/**
 *
 *print collection query 
 */
$Collection->printLogQuery(true);

You can then view the result query.
For developer, enable the system log settings by
System -> Configuration -> Developer -> Log Settings
see the generated log file in [magento_root_folder]/var/log/ folder