productCollectionFactory load function gives data in query but not in object

$collection = $this->_productCollectionFactory->create()
            ->addAttributeToFilter('status', '1')
            ->addAttributeToFilter('featured', '1')

and after this i calling load() function


and after that applying JOIN's

                ['cp' => $collection->getTable('custom_product')], 'e.entity_id = cp.marketplace_product_id'

some other JOIN's


In collection query i am getting perfect query with JOIN table's data.

foreach ($collection as $key => $data){
    $responce[$key]['custom_price'] = $data->getCustomSpecialPrice();

I am getting all custom_special_price and other JOIN fields DATA IN Query But not in foreach.

But when i don't use load() function it gives me data using get method ,But when i do use load() function it doesn't.

So my question is why Magento loads data in Query ? But not in Object.

What load() function is doing with generating query ?

and why those data which is available in query but not in object ?

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.