0

I'm using Magento 2.3.4 , and tried to load a product collection that has original price higher then final price like this:

    $collection = $this->productCollection->create()->addAttributeToSelect('*')
        ->addAttributeToFilter('visibility', array('neq' => \Magento\Catalog\Model\Product\Visibility::VISIBILITY_NOT_VISIBLE))
        ->addAttributeToFilter('status', array('eq' => \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED));

    $this->_stockFilter->addInStockFilterToCollection($collection); 

    $collection->addFinalPrice()->addMinimalPrice();
    //print_r($collection->getData());exit; //empty array
    $collection->getSelect()
        ->where('price_index.final_price < price_index.price');

when i tried to print $collection->getData() using print_r after $collection->addFinalPrice()->addMinimalPrice(); it always return an empty array

Your Answer

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

Browse other questions tagged or ask your own question.