Skip to main content

Posts

Showing posts from April, 2016

update order customer if mismatch after migration like any issue

Using csv we can update customer ids use this code in controller  if (($handle = fopen("/chroot/home/*****/*********/html/app/code/Test/Testmodule/Controller/Index/uniqueorder.csv", "r")) !== FALSE) {             while (($data = fgetcsv($handle, 10000, ",")) !== FALSE) {                 $email = $data[2]; //                 echo $url;die("data");                 $objectManager = \Magento\Framework\App\ObjectManager::getInstance();                 $orderCollection = $objectManager->create('\Magento\Sales\Model\ResourceModel\Order\CollectionFactory');                 $collection = $orderCollection->create()                         ->addAttributeToSelect('*')                         ->load();                 foreach ($collection as $order) {                     if ($order->getCustomerId() != NULL && $order->getCustomerEmail() == $email) {                         $customerData = $objectManage

Magento 2 Useful snippets for frontend developers

1 - Infos About Store Get Current store Id : inject \Magento\Store\Model\StoreManagerInterface $storeManage   $this->storeManager = $storeManager;   and get the id with :   $id = $this->storeManager->getStore()->getId();   get base Url :   $baseUrl = $this->storeManager->getStore()->getBaseUrl();     you can inject \Magento\Framework\UrlInterface and use use constants of class as parameters (UrlInterface::URL_TYPE_LINK) :       const URL_TYPE_LINK = 'link';     const URL_TYPE_DIRECT_LINK = 'direct_link';     const URL_TYPE_WEB = 'web';     const URL_TYPE_MEDIA = 'media';     const URL_TYPE_STATIC = 'static';     const URL_TYPE_JS = 'js';   get base currency code  or (getBaseCurrency() , getDefaultCurrencyCode(), getDefaultCurrency()):   $baseCurrency = $this->storeManager->getStore()->getBaseCurrencyCode();   get current currency code or (getCurrentCur