All posts by Sivakumar

Stock Table Creation: Detail/list Page loading issue. Magento 2

dbusername = Database Name 
localhost = Use Host IP
dbname = Database Name
CREATE ALGORITHM=UNDEFINED DEFINER=`dbusername`@`localhost` SQL SECURITY INVOKER VIEW `inventory_stock_1`  AS  select distinct `legacy_stock_status`.`product_id` AS `product_id`,`legacy_stock_status`.`website_id` AS `website_id`,`legacy_stock_status`.`stock_id` AS `stock_id`,`legacy_stock_status`.`qty` AS `quantity`,`legacy_stock_status`.`stock_status` AS `is_salable`,`product`.`sku` AS `sku` from (`dbname`.`cataloginventory_stock_status` `legacy_stock_status` join `dbname`.`catalog_product_entity` `product` on((`legacy_stock_status`.`product_id` = `product`.`entity_id`)));
Example:
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`127.0.0.1` SQL SECURITY INVOKER VIEW `inventory_stock_1`  AS  select distinct `legacy_stock_status`.`product_id` AS `product_id`,`legacy_stock_status`.`website_id` AS `website_id`,`legacy_stock_status`.`stock_id` AS `stock_id`,`legacy_stock_status`.`qty` AS `quantity`,`legacy_stock_status`.`stock_status` AS `is_salable`,`product`.`sku` AS `sku` from (`exampledatabasename`.`cataloginventory_stock_status` `legacy_stock_status` join `exampledatabasename`.`catalog_product_entity` `product` on((`legacy_stock_status`.`product_id` = `product`.`entity_id`)));

Category Page loading issue, (Exception #0 (DomainException): Undefined factory mysql)

Category Page loading issue, if that page have sidebar "search/engine" tracking.
Step 1: Check Catalog Search Default Search Engine options under catalog menu and enable Mysql Engine
Step 2: Check Other Catalog Search Extensions Modules
Example: Advanced Search,Auto Complete Search Extensions 
Step 3: Update the 'core_config_data' table 'catalog/search/engine' path value using below code
UPDATE core_config_data set value = 'mysql' where path='catalog/search/engine'	 // As default its mysql2

Add attribute name to configurable select option in Magento2?

Open the file

magento/vendor/magento/module-configurable-product/view/frontend/web/js/configurable.js

and find this line

element.options[0].innerHTML = this.options.spConfig.chooseText

repleace the line with below code

var attribute_lable = this.options.spConfig.attributes[element.id.replace(/[a-z]*/, '')]['label'];
element.options[0].innerHTML = this.options.spConfig.chooseText + attribute_lable;

On page load change dropdown label,
Open the file

vendor\magento\module-configurable-product\view\frontend\templates\product\view\type\options\configurable.phtml

and find the line

<option value=""><?= /* @escapeNotVerified */ __('Choose an Option...') ?></option>

repleace the line with below code

<?php 
$attrlabel = array();(Declared before loop)
$attrlabel[$i] = $_attribute->getProductAttribute()->getStoreLabel();?>
<option value=""><?phpecho 'Choose '.$attrlabel[$i];?></option>

How to get configurable attribute label and value in magento 2?

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->create('Magento\Catalog\Model\Product')->load(**product id**);

$productTypeInstance = $objectManager->get('Magento\ConfigurableProduct\Model\Product\Type\Configurable');
$productAttributeOptions = $productTypeInstance->getConfigurableAttributesAsArray($product);
foreach ($productAttributeOptions as $key => $value) {

    $tmp_option = $value['values'];
    if(count($tmp_option) > 0)
    {
        echo "<h3>".$value['label']."</h3>";
        echo "<select id='".$key."_".$value['label']."'>";
        foreach ($tmp_option as $tmp) 
        {
            echo "<option value='".$key."_".$tmp['value_index']."'>".$tmp['label']."</option>";
        }
        echo "</select>";
    }
}

How to Get Number of Product Reviews Magento 2

Display the average stars and reviews count of product

<?php
$productId = 'your_product_id';
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$reviewFactory = $objectManager->create('Magento\Review\Model\Review');
$product = $objectManager->create('Magento\Catalog\Model\Product')->load($productId);
$storeManager  = $objectManager->create('\Magento\Store\Model\StoreManagerInterface');
$storeId = $storeManager->getStore()->getStoreId();
$reviewFactory->getEntitySummary($product, $storeId);

$ratingSummary = $product->getRatingSummary()->getRatingSummary();
$reviewCount = $product->getRatingSummary()->getReviewsCount();
?>
<?php if($ratingSummary){ ?>
<div class="product-reviews-summary short">
    <div class="rating-summary">
        <div title="<?php echo (int)$ratingSummary; ?>%" class="rating-result">
            <span style="width:<?php echo (int)$ratingSummary; ?>%"><span><?php echo (int)$ratingSummary; ?>%</span></span>
        </div>
    </div>
    <div class="reviews-actions">
        <?php echo __('('.$reviewCount.') Reviews'); ?>
    </div>
</div>
<?php } ?>

Blank admin page after installing Magento 2

Step 1:

open file /vendor/magento/framework/View/Element/Template/File/Validator.php in magento install dir , find

$realPath = $this->fileDriver->getRealPath($path)

replace with :

$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));

Step 2:
open file app/etc/di.xml in magento install dir, find

agento\Framework\App\View\Asset\MaterializationStrategy\Symlink

and replace with

Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

Step 3:
Then go to var/cache , delete all folder / file

Step 4:
refresh the page, done.

Database export Error – Input variables exceeded in phpmyadmin

Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini.

Step1:  xampp -> open php folder and select ‘php.ini’  file

Step2:  find this lines  ‘;max_input_vars = 1000‘  

Step3:  Remove the semi-colon 

like the  ‘max_input_vars = 1000‘  

Step4:  and Update the value 1000 to 10000

Step5: Update the file size 

Step6: Restart Your xampp server

 

 

Update Cron file in Magento and Server

Update Cron file in Magento and Server:

1. Setting up the Magento cronjob using shell access

It is strongly recommended not to run the cronjob under the

crontab -e
root/superuser account. If you are logged in as root, please switch (su) to a non-privileged account.
Before setting up a new cronjob, please make sure the Magento cronjob (a cron running cron.php) hasn’t been set up yet. Use the following command to get the currently installed cronjobs:

If the cronjob hasn’t been set up yet, you will need to open the crontab file to set up the cronjob. The crontab manages which and when cronjobs are run on the server.

crontab -l

Now, go to the end of the last line in the cron tab file and press enter to create a new line.

Enter the following line and replace YOURDOMAIN.com and PATH_TO_MAGENTO with the URL of the root directory of your Magento installation:

*/5 * * * * wget -O /dev/null -q http://www.YOURDOMAIN.com/PATH_TO_MAGENTO/cron.php > /dev/null
 
OR
 
*/5 * * * * /bin/php /var/www/vhosts/YOURDOMAIN/htdocs/cron.php > /dev/null
 
OR
 
*/5 * * * * wget -O /dev/null -q /var/www/vhosts/YOURDOMAIN/htdocs/cron.php > /dev/null
 
OR
 
*/5 * * * * /bin/php -q /var/www/vhosts/YOURDOMAIN/htdocs/cron.php   (Its working for us)

 

It is very important that the cron.php file of Magento gets executed every five minutes. Do not change this to a longer interval.

Please try to call the URL you’ve entered into the cron tab using your browser. A blank page should be returned. If the page can’t be found (404), that means the URL to the cronjob manager of Magento (cron.php) is wrong. This means the cron job won’t execute and hasn’t been set up properly. It is really important you enter the correct URL – it is always the URL to the cron.php file sitting inside the root directory of your Magento installation.

Save the cron tab using CTRL+X, enter y to save the changes and press enter. The following message should be displayed:

crontab: installing new crontab

 

 

Nginx Server Comments Putty Comment

nginx server comments: putty comment :

https://varvy.com/pagespeed/cache-control.html
i to insert
a to append
x to delete
dd to delete a line
: to begin a command sequence
:w to save
:q to quit
:q! to quit without saving
:wq to save and quit

Unstall / install webmin
Sudo apt-get install webmin
Sudo apt-get purge webmin

Unzip Comment
unzip file.zip

Use the following syntax if you want to extract/unzip to a particular destination directory:
unzip -d /dest/directory/ file.zip

Install unzip on Debian/Ubuntu Linux
sudo apt-get install unzip
OR
sudo apt install unzip

Copy the file and Save it in different name. Backup the files using below comment.
How to perform basic copy operation?
cp file1 ~/Desktop

How to make cp prompt before overwriting?
cp -i file1 ~/Desktop/

How to force cp to not overwrite existing file?
cp -n file1 ~/Desktop/

 

Magento New Order Mail Not Sending Admin Issue

 

Note : Check the mail after each steps Completed

Step1 : Email Model Template File

File Path: app/code/core/Mage/Core/Model/Email/Template.php 

Note : Move to local path app/code/local/Mage/Core/Model/Email/Template.php 

Changed the Below line In Your Template.php file

<?php
    if ($this->hasQueue()&& $this->getQueue() instanceof Mage_Core_Model_Email_Queue) /* line number 407 version 1.9.2.2 */
 
  to
 
    if (!($this->hasQueue()) && $this->getQueue() instanceof Mage_Core_Model_Email_Queue)
 
  (or)
    if (!($this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue))
 ?>

Step2 : Sales Model Template File

File Path: app/code/core/Mage/Sales/Model/Order.php 

Note : Move to local path app/code/local/Mage/Sales/Model/Order.php 

Changed the Below line In Your Order.php file

<?php 
  $mailer->setQueue($emailQueue)->send(); 
 
  to
 
  $mailer->send(); 
?>

 

Step3: Check Cron (Scheduled Tasks)  in magento Admin Panel

Path:Configuration -> Advanced -> System -> Cron (Scheduled Tasks) – all the times are in minutes 

Check Below Options is Set Low Values Or Not

‘Generate Schedules’, ‘Every Schedule Ahead for’

 

Step4: Cron File Update

cron.php should be as like Magento Version

Add the Below code in your cron.php file after this line

<?php
$isShellDisabled = is_array($disabledFuncs) ? in_array('shell_exec', $disabledFuncs) : true;
/* line number 47 version 1.9.2.2  */
/* Added Code */ 
$isShellDisabled = true;
?>