Can’t see price in configurable products after csv import

Please do reindex all.

Advertisements

Add columns into the admin grid in Magento2

Follow below steps

1) Vendor/Module/view/adminhtml/ui_component/sales_order_grid.xml

<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<actionsColumn name="shipment" class="Sinelogix\Zepo\Ui\Component\Listing\Column\Shipment">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Vendor_Module/js/grid/columns/shipment</item>
<item name="indexField" xsi:type="string">entity_id</item>
<item name="sortable" xsi:type="boolean">false</item>
<item name="label" xsi:type="string" translate="true">Shipment</item>
<item name="sortOrder" xsi:type="number">13</item>
</item>
</argument>
</actionsColumn>
</columns>
</listing>

2) /Vendor/Module/Ui/Component/Listing/Column/Shipment.php

<?php namespace Sinelogix\Zepo\Ui\Component\Listing\Column; use \Magento\Sales\Api\OrderRepositoryInterface; use \Magento\Framework\View\Element\UiComponent\ContextInterface; use \Magento\Framework\View\Element\UiComponentFactory; use \Magento\Ui\Component\Listing\Columns\Column; use \Magento\Framework\Api\SearchCriteriaBuilder; use \Magento\Framework\UrlInterface; class Shipment extends Column { protected $_orderRepository; protected $_searchCriteria; protected $urlBuilder; public function __construct( ContextInterface $context, UrlInterface $backendUrl, UiComponentFactory $uiComponentFactory, OrderRepositoryInterface $orderRepository, SearchCriteriaBuilder $criteria, array $components = [], array $data = []) { $this->_orderRepository = $orderRepository;
        $this->urlBuilder  = $backendUrl;
        $this->_searchCriteria  = $criteria;
        parent::__construct($context, $uiComponentFactory, $components, $data);
    }

    public function prepareDataSource(array $dataSource)
    {
		if (isset($dataSource['data']['items'])) {
            $fieldName = $this->getData('name');
			
            foreach ($dataSource['data']['items'] as & $item) {
				$url = $this->urlBuilder->getUrl('zepo',['order_id'=>$item['entity_id']]);
                $item[$fieldName . '_html'] = "<a href='".$url."'><span>Ship</span></a>";
				$item[$fieldName . '_orderid'] = $item['entity_id'];
                $item[$fieldName . '_formaction'] = $url;
            }
        }
        return $dataSource;
    }
}

3) /Vendor/Module/view/base/web/js/grid/columns/shipment.js


define([
    'Magento_Ui/js/grid/columns/column',
    'jquery',
    'mage/template',
    'text!Sinelogix_Zepo/templates/grid/cells/customer/shipment.html',
    'Magento_Ui/js/modal/modal'
], function (Column, $, mageTemplate, sendmailPreviewTemplate) {
    'use strict';
    
    return Column.extend({
        defaults: {
            bodyTmpl: 'ui/grid/cells/html',
            fieldClass: {
                'data-grid-html-cell': true
            }
        },
        gethtml: function (row) {
            return row[this.index + '_html'];
        },
        getFormaction: function (row) {
            return row[this.index + '_formaction'];
        },
        getOrderid: function (row) {
            return row[this.index + '_orderid'];
        },
        getLabel: function (row) {
            return row[this.index + '_html']
        },
        getTitle: function (row) {
            return row[this.index + '_title']
        },
        getSubmitlabel: function (row) {
            return row[this.index + '_submitlabel']
        },
        getCancellabel: function (row) {
            return row[this.index + '_cancellabel']
        },
        preview: function (row) {
            window.location = this.getFormaction(row);
        },
        getFieldHandler: function (row) {
            return this.preview.bind(this, row);
        }
    });
});

Migration from magento1 to magento2

Follow below steps to migrate the webstie

Download extension from ubertheme and follow the steps from docs.

After migration done using above module solve errors which was arrive in admin or frontend

if u want to migrate latest orders and customers, migrate in new database using above module and just move rows from orders and customers table.

sales_orders
sales_order_address
sales_order_aggregated_created
sales_order_aggregated_updated
sales_order_grid
sales_order_item
sales_order_payment
sales_order_status
sales_order_status_history
sales_bestsellers_aggregated_daily
sales_bestsellers_aggregated_monthly
sales_bestsellers_aggregated_yearly
sales_creditmemo
sales_creditmemo_comment
sales_creditmemo_grid
sales_creditmemo_item
sales_invoice
sales_invoiced_aggregated
sales_invoiced_aggregated_order
sales_invoice_comment
sales_invoice_grid
sales_invoice_item
sales_payment_transaction
sales_refunded_aggregated
sales_refunded_aggregated_order
sales_shipment
sales_shipment_comment
sales_shipment_grid
sales_shipment_item
sales_shipment_track
sales_shipping_aggregated
sales_sequence_meta

You will get error on the shipment address. please search the error from error log and resolve it.

Free Shipping of a single product in magento2

Step1:– Enable shipping method. with minimum amount 99999999.999

Step2:- Create one product attribute for Free Shipping method selection.

Step3:- Create one Catalog Price Rule.

Step4:- Add one action with Free Shipping value is For matching Items only

Step5:- For the rules, keep the default “if ALL of these conditions are TRUE”. Click the plus sign to add a condition. Select Free Shipping from the list.  and select it’s value to true or 1.

 

 

Magento 2 Get product image


$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

<span 				data-mce-type="bookmark" 				id="mce_SELREST_start" 				data-mce-style="overflow:hidden;line-height:0" 				style="overflow:hidden;line-height:0" 			></span>$imageHelper  = $objectManager->get('\Magento\Catalog\Helper\Image'); $imageHelper  = $objectManager->get('\Magento\Catalog\Helper\Image'); $image_url = $imageHelper->init($_item, 'product_page_image_small')->setImageFile($_item->getFile())->resize(100, 100)->getUrl();

How to remove or limit the Mass Action in Magento2

1) Create the file in your module with the path  /app/code/Vendor/Module/view/adminhtml/ui_component/product_listing.xml

Here i am taking the example of Product page.


<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<listingToolbar name="listing_top">
<massaction name="listing_massaction" class="Vendor\Module\Ui\MassAction"/>
</listingToolbar>
</listing>

2) Create The class for modify the mass option at below path.
/app/code/Vendor/Module/Ui/MassAction.php


<?php namespace Vendor\Module\Ui; class MassAction extends \Magento\Ui\Component\MassAction { private $authorization; public function __construct( \Magento\Framework\View\Element\UiComponent\ContextInterface $context, \Magento\Framework\AuthorizationInterface $authorization, $components, array $data ) { $this->authorization = $authorization;
parent::__construct($context, $components, $data);
}

public function prepare()
{
parent::prepare();
$config = $this->getConfiguration();
//if (!$this->authorization->isAllowed('Magento_Catalog::the_acl_youd_like_to_use')) {
$allowedActions = [];
foreach ($config['actions'] as $action) {
if ('delete' != $action['type']) {
$allowedActions[] = $action;
}
}
$config['actions'] = $allowedActions;
//}
$this->setData('config', (array)$config);
}
}

Magento add checkbox and searchbox in Layer Filter

1)Replace the below code in files app/design/frontend/{yourtheme}/default/template/catalog/layer/view.phtml

<?php if($this->canShowBlock()): ?>
<div class="block block-layered-nav">
<div class="block-title">
<strong><span><?php echo $this->__('Shop By') ?></span></strong></div>
<div class="block-content">
<?php echo $this->getStateHtml() ?>
<?php if ($this->getLayer()->getState()->getFilters()): ?>
<div class="actions"><a class="btn btn-default" href="<?php echo $this->getClearUrl() ?>"><i class="icon-trash"></i><?php echo $this->__('Clear All') ?></a></div>
<?php endif;?>
<?php if( $this->canShowOptions()): ?>

<?php echo $this->__('Shopping Options') ?>
<dl id="narrow-by-list" class="clearfix">
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<dt><?php echo $this->__($_filter->getName()) ?></dt>

<dd<?php echo ($this->__($_filter->getName()) == $this->__('Category') ? ' class="category-filter"' : ''); ?>>
<?php if($this->__($_filter->getName())!= $this->__('Price') ):?>
<input type="text" placeholder="<?php echo $this->__('Search for option'); ?>" class="quick-search form-control" />
<?php endif;?>
<?php echo $_filter->getHtml() ?>
</dd>

<?php endif; ?>
<?php endforeach; ?>
</dl>

<script type="text/javascript">
 decorateDataList('narrow-by-list');
 </script>
<?php endif; ?></div>
</div>
<?php endif; ?>

<script type="text/javascript">
jQuery(document).ready(function(){
jQuery(document).on('change','.ccheckbox', function() {
 jQuery(this).siblings('a').trigger("click");
 });
 jQuery(document).on('keyup','.quick-search',function(){
if(jQuery(this).val() != ''){
//alert('');
 var term = jQuery(this).val();
term = term.toLowerCase();
 jQuery(this).siblings('ol').find('li').each(function(){
 if( jQuery(this).find('a').text().toLowerCase().indexOf(term) >= 0 ){
 jQuery(this).show();
 } else {
 jQuery(this).hide();
 }
 });
}else{
jQuery(this).siblings('ol').find('li').each(function(){ 
 jQuery(this).show();
 });}
 });
 
});
 </script>

2)  Add below code in file /app/design/frontend/{yourtheme}/default/template/catalog/layer/filter.phtml

<ol>
<?php $selection = FALSE; $items = $this->getItems();
foreach ($this->getItems() as $_item)
{
if ($_item->isSelected())
{
$selection = TRUE;
$removal_url=$_item->getRemoveUrl();
break;
}
}
?>

<?php foreach ($this->getItems() as $_item): ?>
<?php $code =$_item->getFilter()->getAttributeModel()->getAttributeCode();
if($code !="price") {
$lable = $_item->getLabel();
}else{
$lable = '';
}

?>
	<li label="<?php echo $lable ?>">
<?php if( $_item->isSelected() ) : ?>
<input class="ccheckbox" type="checkbox" checked/>
<a style="color: #D96708" class="multi-select isselected" href="<?php echo $removal_url ?>">
<?php echo $_item->getLabel() ?></a>
<?php else : ?>
<input type="checkbox" class="ccheckbox"/>
<a style="color: #666633" class="multi-select unselected" href="<?php echo $this->urlEscape($_item->getUrl()) ?>">
<?php echo $_item->getLabel() ?></a>
<?php endif; ?></li>
<?php endforeach ?></ol>

3) Replace below line in file app/code/core/Mage/Catalog/Model/Resource/Layer/Filter/Attribute.php


// $tableAlias = $attribute->getAttributeCode() . '_idx';
$tableAlias = $attribute->getAttributeCode() . '_idx_'.$value;

4)  Comment below line in file app/code/core/Mage/Catalog/Model/Layer/Filter/Attribute.php

// $this->_items = array(); Line 96

5) Add below function in file app/code/core/Mage/Catalog/Model/Layer/Filter/Item.php


public function isSelected(){
$selected = Mage::getSingleton('core/app')->getRequest()->getParam($this->getFilter()->getRequestVar());

if($selected == $this->getValue()){
return true;
}else{
return false;
}
}