Monday 4 July 2022

How to add custom value prefix in order and invoice number. in magento 2

 How to add custom value prefix in order and invoice number.


I like to add prefix in order and invoice number and next number should be in current year and last 4 digit is Increment number, this are all without extension.


Example: 0001 to aa-yy0001



sales_sequence_profile:



For invoice: 

UPDATE sales_sequence_profile SET prefix = 'aa-yy' WHERE meta_id = 6;


For order: 

UPDATE sales_sequence_profile SET prefix = 'Pic_' WHERE meta_id = 5;

Thursday 4 June 2020

Magento 2 all essential command line

To enable the cache:
php bin/magento cache:enable

To disable the cache:
php bin/magento cache:disable

To flush the cache:
php bin/magento cache:flush

A short command line:
php bin/magento c:f

To clean the cache in the website:
php bin/magento cache:clean

A short command line:
php bin/magento c:c


To view a list of all indexers:
php bin/magento indexer:info

View indexer status:
php bin/magento indexer:status

Reindex Command options:
php bin/magento indexer:reindex

If you want to reindex only one indexer then write following command:
php bin/magento indexer:reindex indexer_name
ex: php bin/magento indexer:status catalog_category_product

In case you fill memory limit, try this command
php -d memory_limit=10G bin/magento indexer:reindex

If any index is looping You can reset all index by using
php bin/magento indexer:reset

Current application mode:
php bin/magento deploy:mode:show

Set to production mode:
php bin/magento deploy:mode:set production

Set to developer mode:
php bin/magento deploy:mode:set developer

Set to default mode:
php bin/magento deploy:mode:set default


To install a non-optional CRON job:
php bin/magento cron:install

To remove the Magento crontab:
php bin/magento cron:remove

Run cron from the command line:
php bin/magento cron:run

To run the indexing cron job, enter:
php bin/magento cron:run --group index

To run the default cron job, enter:
php bin/magento cron:run --group default

If you enabled one or more modules, then you will need to run magento
setup:upgrade to update the database schema:
php bin/magento module:enable Nwdthemes_Module
php bin/magento setup:upgrade

1.Reach out to Smartwave extension's support team to
get the idea if they have any fix or suggestion.

2.If you do not need Smartwave_Dailydeals extension than
disable that extension / module and compile again.
3. on Magento Stack exchange a similar bug is reported
and is fixed as well, please try if that helps to fix your issue
:-
php bin/magento setup:di:compile

Simple run the following command line to deploy static content
your store when install / update an extension:
php bin/magento setup:static-content:deploy

Magento admin user created by command line:
php bin/magento admin:user:create --admin-user='adminuser' --admin-password='admin#123' --admin-email='test@test.com' --admin-firstname='Test' --admin-lastname='Tester'

How to Unlock Admin User via Command Line:
php bin/magento admin:user:unlock username
ex php bin/magento admin:user:unlock admin


Thursday 30 April 2020

How To Validate Custom Form in Magento 2

<form class="form" id="custom-form" method="post" autocomplete="off" data-mage-init='{"validation": {}}'>

   <fieldset class="fieldset">

       <legend class="legend"><span><?php echo __('Personal Information') ?></span></legend><br>
     
       <div class="field name required">
          <label class="label"><?php echo __('Name') ?>:</label>
          <div class="control">
            <input type="text"  name="name" id="name" class="input-text"  data-validate="{required:true, }" />
          </div>
      </div>

        <div class="field email required">

            <label for="email_address" class="label"><span><?php echo __('Email') ?></span></label>

            <div class="control">

                <input type="email" name="email" id="email" value="" title="<?php echo __('Email') ?>" class="input-text" data-validate="{required:true, 'validate-email':true}">

            </div>

        </div>

   </fieldset>

   <div class="actions-toolbar">

        <div class="primary">

            <button type="submit" class="action submit primary" title="<?php  echo __('Submit') ?>"><span><?php echo __('Submit') ?></span></button>

        </div>

    </div>

</form>



<script type="text/javascript">

require([

    'jquery',

    'mage/mage'

], function($){



   var dataForm = $('#custom-form');

   dataForm.mage('validation', {});



});

</script>

Wednesday 8 April 2020

Magento 2.x | Can't Access Web Setup Wizard | Welcome to Magento Admin, your online store headquarters. To use the Magento setup wizard sign into your Admin account and navigate to System => Tools => Web Setup Wizard


Solution for me was:
Base URLs (Secure)
-> Use Secure URLs on Storefront -> Yes
-> Use Secure URLs in Admin -> Yes
-> Enable HTTP Strict Transport Security (HSTS) -> Yes
-> Upgrade Insecure Requests -> Yes
php bin/magento cache:clean

I SOLVE THIS.

Friday 3 April 2020

Magento 2 how to move category title to above description

catalog_category_view.xml at below location

app/design/frontend/Package/theme/Magento_Catalog/view/frontend/layout

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
    <move element="columns.top" destination="content" before="-"/>
    </body>
</page>

Thursday 2 April 2020

How to Expand default Layered Navigation Category Filters in Magento 2

app\design\frontend\Themes\Yourtheme\Magento_LayeredNavigation\templates\layer\view.phtml
Now, Search for the below code, you will find that code around line no-32.


<?php foreach ($block->getFilters() as $filter): ?>
                <?php if ($filter->getItemsCount()): ?>
                    <?php if (!$wrapOptions): ?>
                        <strong role="heading" aria-level="2" class="block-subtitle filter-subtitle"><?= / @escapeNotVerified / __('Shopping Options') ?></strong>
                        <div class="filter-options" id="narrow-by-list" data-role="content" data-mage-init='{"accordion":{"openedState": "active", "collapsible": true, "active": false, "multipleCollapsible": false}}'>
                    <?php  $wrapOptions = true; endif; ?>
                    <div data-role="collapsible" class="filter-options-item">
                        <div data-role="title" class="filter-options-title"><?= / @escapeNotVerified / __($filter->getName()) ?></div>
                        <div data-role="content" class="filter-options-content"><?= / @escapeNotVerified / $block->getChildBlock('renderer')->render($filter) ?></div>
                    </div>
                <?php endif; ?>
            <?php endforeach; ?>


 And replace that piece code with below-given code.

 <?php foreach ($block->getFilters() as $filter): ?>
<?php if ($filter->getItemsCount()): ?>
    <?php if (!$wrapOptions): ?>
        <?php $collapsibleRange = implode(' ', range(0, $filter->getItemsCount())); ?>
        <strong role="heading" aria-level="2" class="block-subtitle filter-subtitle"><?php /* @escapeNotVerified */ echo __('Shopping Options') ?></strong>
        <div class="filter-options" id="narrow-by-list" data-role="content" data-mage-init='{"accordion":{"openedState": "active", "collapsible": true, "active": "<?php echo $collapsibleRange ?>", "multipleCollapsible": true}}'>
    <?php  $wrapOptions = true; endif; ?>
    <div data-role="collapsible" class="filter-options-item">
    <div data-role="title" class="filter-options-title"><?php /* @escapeNotVerified */ echo __($filter->getName()) ?></div>
    <div data-role="content" class="filter-options-content"><?php /* @escapeNotVerified */ echo $block->getChildBlock('renderer')->render($filter); ?></div>
</div>
<?php endif; ?>