How to get customer data by id in Magento2 ?
$customerID = 10;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerObj = $objectManager->create('Magento\Customer\Model\Customer')
->load($customerID);
$customerEmail = $customerObj->getEmail();
-> How to get customer collection in Magento2 ?
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerObj = $objectManager->create('Magento\Customer\Model\Customer')->getCollection();
foreach($customerObj as $customerObjdata ){
print_r($customerObjdata ->getData());
}
-> How to get order collection in Magento2 ?
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();$orderDatamodel = $objectManager->get('Magento\Sales\Model\Order')->getCollection();
foreach($orderDatamodel as $orderDatamodel1){
print_r($orderDatamodel1->getData());
}
-> How to get the order items from the order in Magento2 ?
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$orderDatamodel = $objectManager->get('Magento\Sales\Model\Order')->getCollection();
foreach($orderDatamodel as $orderDatamodel1){
$getid = $orderDatamodel1->getData("increment_id");
$orderData = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($getid);
//echo "<pre>";
$getorderdata = $orderData->getData();
$orderItems = $orderData->getAllVisibleItems();
foreach($orderItems as $orderItems){
print_r($orderItems->getData());
}
}
- > How to get all storesin Magento2 ?
function getallstores(){
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$connection = $objectManager->get('Magento\Framework\App\ResourceConnection')->getConnection('\Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION');
$result1 =
$connection->fetchAll("SELECT store_id ,name FROM store");
return $result1;
}
-> How to get attribute options by attribute code in Magento2
<?php$objectManager1 = \Magento\Framework\App\ObjectManager::getInstance();
$manufacturerOptions = $objectManager1->create('\Magento\Catalog\Model\Product\Attribute\Repository')->get('manufacturer')->getOptions();
foreach ($manufacturerOptions as $manufacturerOption) {
echo $manufacturerOption->getValue();
echo $manufacturerOption->getLabel();
?>