How can I get all attributes of product with its values? I mean attributes like size, color, gender and like that, but not availablity, quantity or sku. I need to use them for filters, how can I get it?

2 Answers 2


you have write on block class file

namespace Pradip\Magegig\Block;
class Products extends \Magento\Framework\View\Element\Template
    protected $_productCollectionFactory;

    public function __construct(
        \Magento\Backend\Block\Template\Context $context,        
        \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,        
        array $data = []
        $this->_productCollectionFactory = $productCollectionFactory;    
        parent::__construct($context, $data);

    public function getProductCollection()
        $collection = $this->_productCollectionFactory->create();
        return $collection;

in Phtml file you will getting all attribute along with product

$productCollection = $block->getProductCollection();
foreach ($productCollection as $product) {
    echo "<br>";
  • It is not what I ask. Also my ask for magento 1.9 - not 2.
    – makz
    Commented Oct 22, 2019 at 20:03

Please check the link. Which have all the answer of your question.


  • There no answer for my question.
    – makz
    Commented Oct 22, 2019 at 20:05
  • Means I am not getting you.
    – Mayur
    Commented Oct 23, 2019 at 4:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.