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?


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>";
| improve this answer | |
  • It is not what I ask. Also my ask for magento 1.9 - not 2. – makz Oct 22 '19 at 20:03

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


| improve this answer | |
  • There no answer for my question. – makz Oct 22 '19 at 20:05
  • Means I am not getting you. – Mayur Oct 23 '19 at 4:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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