Wednesday, 2 January 2019

Magento 2 Export order,customer and products tables only

Customer Tables Export

mysqldump -u username -p dbname customer_address_entity customer_address_entity_datetime customer_address_entity_decimal customer_address_entity_int customer_address_entity_text customer_address_entity_varchar customer_entity  customer_entity_datetime customer_entity_decimal customer_entity_int customer_entity_text customer_entity_varchar  customer_grid_flat customer_log customer_visitor persistent_session wishlist wishlist_item  wishlist_item_option > hkcustomers31dec.sql


Orders Tables Export


mysqldump -u username -p dbname gift_message quote quote_address quote_address_item quote_id_mask quote_item quote_item_option quote_payment  quote_shipping_rate reporting_orders 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_order sales_order_address sales_order_aggregated_created sales_order_aggregated_updated sales_order_grid sales_order_item sales_order_payment sales_order_status_history sales_order_tax sales_order_tax_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_shipping_aggregated_order tax_order_aggregated_created  tax_order_aggregated_updated > hkorders31dec.sql

Product Tables List

cataloginventory_stock_item cataloginventory_stock_status cataloginventory_stock_status_idx cataloginventory_stock_status_tmp catalog_category_product catalog_category_product_index catalog_category_product_index_tmp catalog_compare_item catalog_product_bundle_option catalog_product_bundle_option_value catalog_product_bundle_price_index catalog_product_bundle_selection catalog_product_bundle_selection_price catalog_product_bundle_stock_index catalog_product_entity catalog_product_entity_datetime catalog_product_entity_decimal catalog_product_entity_gallery catalog_product_entity_int catalog_product_entity_media_gallery catalog_product_entity_media_gallery_value catalog_product_entity_media_gallery_value_to_entity catalog_product_entity_media_gallery_value_video catalog_product_entity_text catalog_product_entity_tier_price catalog_product_entity_varchar catalog_product_index_eav catalog_product_index_eav_decimal catalog_product_index_eav_decimal_idx catalog_product_index_eav_decimal_tmp catalog_product_index_eav_idx catalog_product_index_eav_tmp catalog_product_index_price catalog_product_index_price_bundle_idx catalog_product_index_price_bundle_opt_idx catalog_product_index_price_bundle_opt_tmp catalog_product_index_price_bundle_sel_idx catalog_product_index_price_bundle_sel_tmp catalog_product_index_price_bundle_tmp catalog_product_index_price_cfg_opt_agr_idx catalog_product_index_price_cfg_opt_agr_tmp catalog_product_index_price_cfg_opt_idx catalog_product_index_price_cfg_opt_tmp catalog_product_index_price_downlod_idx  catalog_product_index_price_downlod_tmp catalog_product_index_price_final_idx catalog_product_index_price_final_tmp catalog_product_index_price_idx catalog_product_index_price_opt_agr_idx catalog_product_index_price_opt_agr_tmp catalog_product_index_price_opt_idx catalog_product_index_price_opt_tmp catalog_product_index_price_tmp catalog_product_index_tier_price catalog_product_index_website catalog_product_link catalog_product_link_attribute_decimal catalog_product_link_attribute_int catalog_product_link_attribute_varchar catalog_product_option catalog_product_option_price catalog_product_option_title catalog_product_option_type_price catalog_product_option_type_title catalog_product_option_type_value catalog_product_relation catalog_product_super_attribute catalog_product_super_attribute_label catalog_product_super_link catalog_product_website catalog_url_rewrite_product_category downloadable_link downloadable_link_price downloadable_link_purchased downloadable_link_purchased_item downloadable_link_title downloadable_sample downloadable_sample_title product_alert_price product_alert_stock report_compared_product_index report_viewed_product_aggregated_daily report_viewed_product_aggregated_monthly report_viewed_product_aggregated_yearly report_viewed_product_index

Friday, 2 November 2018

How to remove empty attributes “No” in Magento 2?

 Override the to your theme
 app/code/{Packagename}/{themename}/Magento_Catalog/templates/product/view/attributes.phtml


Just keep line, <?php if($_data['value'] == 'N/A') continue;?> after <?php foreach ($_additional as $_data): ?> line,


 Full code,

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

/**
 * Product additional attributes template
 *
 * @var $block \Magento\Catalog\Block\Product\View\Attributes
 */
?>
<?php
    $_helper = $this->helper('Magento\Catalog\Helper\Output');
    $_product = $block->getProduct();
?>
<?php if ($_additional = $block->getAdditionalData()): ?>
    <div class="additional-attributes-wrapper table-wrapper">
        <table class="data table additional-attributes" id="product-attribute-specs-table">
            <caption class="table-caption"><?= /* @escapeNotVerified */ __('More Information') ?></caption>
            <tbody>
            <?php foreach ($_additional as $_data): ?>
<?php if($_data['value'] == 'No') continue;?>
                <tr>
                    <th class="col label" scope="row"><?= $block->escapeHtml(__($_data['label'])) ?></th>
                    <td class="col data" data-th="<?= $block->escapeHtml(__($_data['label'])) ?>"><?= /* @escapeNotVerified */ $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>
<?php endif;?>

Thursday, 12 July 2018

Msgento Export the all Orders into CSV with Limited Headers

<?php
require_once('app/Mage.php');
    Mage::app();

    $data=Mage::getModel('sales/order')->getCollection();

$fp = fopen('exports_order.csv', 'w+');
//csve headers. You can give your own headers or extra headers
$csvHeader = array('order_id',
    'ship_name',
    'ship_address1',
    'ship_city',
    'ship_state',
    'ship_zip',
    'ship_country',
    'item_id',
    'qty',
    'ship_company',
    'phone_day',
    'email');
fputcsv( $fp, $csvHeader,",");
foreach($data as $row)
{
    //echo "<pre>";Mage::log($row->getData(),null,'orderdata.log');die('here');
    $_order=Mage::getModel('sales/order')->load($row->getId());
    $_shippingAddress = $_order->getShippingAddress();
    //echo "<pre>";Mage::log($_shippingAddress->getData(),null,'shipping.log');die('here');
    foreach ($row->getAllItems() as $item) {
    $product = Mage::getModel('catalog/product')->load($item->getProductId());
 
//echo "<pre>";Mage::log($item->getData(),null,'noworders.log');die();
fputcsv($fp, array($row->getId(),
    $_shippingAddress->getFirstname()." ".$_shippingAddress->getLastname(),
    $_shippingAddress->getStreetFull(),
    $_shippingAddress->getCity(),
    $_shippingAddress->getRegion(),
    $_shippingAddress->getPostcode(),
    $_shippingAddress->getCountry_id(),
    $item->getSku(),
    $item->getQtyOrdered(),
    $_shippingAddress->getCompany(),
    $_shippingAddress->getTelephone(),
    $_shippingAddress->getEmail()
    ) );

    }
 
}
fclose($fp);

Create Shipment for Order Using Script

<?php
$orderid = 1;
$order = Mage::getModel('sales/order')->load($orderid );
$shipmentItems = array();
foreach ($order->getAllItems() as $item) {
$shipmentItems [$item->getId()] = $item->getQtyToShip();
}

// Prepear shipment and save ....
if ($order->getId() && !empty($shipmentItems) && $order->canShip()) {
    $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($shipmentItems);
    $shipment->save();
}
$shipment_collection = Mage::getResourceModel('sales/order_shipment_collection');
$shipment_collection->addAttributeToFilter('order_id', $data[0]);
foreach($shipment_collection as $sc) {
    $shipment = Mage::getModel('sales/order_shipment');
    $shipment->load($sc->getId());
    if($shipment->getId() != '') {
$track = Mage::getModel('sales/order_shipment_track')
->setShipment($shipment)
->setData('title', $data[5])
->setData('number', $data[6])
->setData('order_id', $shipment->getData('order_id'))
->save();
    }
}
?>

Monday, 10 July 2017

Magento get All search terms using programatically

<?php
//echo "hiii";die("here");
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once(__DIR__ . '/app/Mage.php');
Mage::app();
umask(0);
$searchCollection=Mage::getModel('catalogsearch/query')->getCollection();
//echo "<pre>";print_r($searchCollection->getData());die("here");
$searchData = $searchCollection->getData();
foreach($searchData as $terms){
echo $terms['query_text'];
echo "<br />";
}
die("here");
?>

Friday, 7 July 2017

Magento2 Upgrade from 2.0.x-2.1.x

In composer.json change this line
"magento/product-community-edition": "2.0.0",
Also you should change the line 5 as well "version": "2.0.0", to keep it in sync.
to whatever version you want, and then run:
composer update
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
if any Authenication required give the public keys and private keys 
as a username and password of Your magento.com account login

Magento 9767 patch issue in checkout page customer registration

Product Collection with out of stock and In Stock in Magento 2

Product collection with out of stock and In stock. use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; $collection = $th...