magecurious
magecurious
Untitled
5 posts
Don't wanna be here? Send us removal request.
magecurious · 9 months ago
Text
How to get Product Collection in Magento 2
Hello Everyone,
In this blog, we will learn about how to get Product Collection in Magento 2.
Product Collection means showing the items in your Magento 2 Store when you run the command.
Without wasting your time, let us guide you straight away. Follow the easy step given below to get Product Collection in Magento 2.
STEPS FOR GET PRODUCT COLLECTION IN MAGENTO 2
Step 1: Create Hello.php file
app/code/Vendor/Extension/Block/Hello.php
<?php
namespace Vendor\Extension\Block;
class Hello extends \Magento\Framework\View\Element\Template
{
          protected $productFactory;
    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productFactory,
        array $data = []
    )
    {
        $this->productFactory = $productFactory;
        parent::__construct($context, $data);
    }
    public function getProductCollection()
    {
        $collection = $this->productFactory->create();
        return $collection;
    }
}
Now We Print Product Collection in .phtml file. We call getProductCollection() method from our block.
<?php
$productCollection = $block->getProductCollection();
foreach ($productCollection as $product) {
    echo “<pre>”;
    print_r($product->getData());
    echo “</pre>”;
}
Final Thoughts:
So this was the easiest way which we have told you in this blog. This is how you can get Product Collection in Magento 2. Hope you liked the blog.
So quickly go to the comment box and tell me how you like this blog?
Stay tuned with us on our site to get new updates of Magento.
Thanks for reading and visiting our site.
0 notes
magecurious · 1 year ago
Text
About Freedom Cars
Freedom Cars gives anybody who applies the best chance to get a vehicle and experience freedom. No more bus fares, taxi fares or waiting on friends for a lift. We offer a chance to take back your independence and an opportunity to repair your credit rating – even if you’re bankrupt, unemployed or receiving a Centrelink pension.
0 notes
magecurious · 1 year ago
Text
Magento 2 Sign In with Google One Tap
This extension will automatically show a Google one-tab login popup on the store owner's website so that customers can easily register and log in on devices that are logged in with a Google account, and there is no interruption in filling out signup forms. Magento 2 simply has a better user experience, customer registration, and higher rate of your store with a one tap sign-in feature where users don't have to wait to get into the store.
0 notes
magecurious · 1 year ago
Text
Payment Fee
Magento2 Payment Fee Extension by MageCurious allows e-commerce store owner to add some extra fees while their customer process the order in e-commerce store based on payment method selection.Store owner can set different payment charges for different payment methods by customer group with different fees type including Fixed Price as well as Percentage of subtotal.
0 notes
magecurious · 1 year ago
Text
Add to Cart
Magento 2 Extension Add to Cart extension is very popular extension of magecurious and is enhance user experience.
1 note · View note