Im creating a custom product Api with searchCriteria from \Magento\Catalog\Model\ResourceModel\Product\Collection

And I joined other table to this collection;

public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
    /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */
    $collection = $this->collectionFactory->create();
    $collection->getSelect()->joinLeft(array("vendorProduct"=>'ced_csmarketplace_vendor_products'), 'e.entity_id = vendorProduct.product_id',array('vendor_id' => "vendor_id"));

    $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
    $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');

    $this->collectionProcessor->process($searchCriteria, $collection);


    $searchResult = $this->searchResultsFactory->create();

    return $searchResult;

The joined data not show when I call this Api.

But if I "return $collection->getData();" it will show the joined data.

enter image description here

  • in both screenshot, I see the identical data, am I missing something? Commented Jun 26, 2020 at 16:48
  • Sorry, I uploaded a wrong image. Commented Jun 27, 2020 at 13:33
  • you may add your webapi.xml file and your repository function at least for us to know where you get it wrong.. Of course we can do it all from scratch but who will? Commented Jun 27, 2020 at 13:37

1 Answer 1


The searchResult is the result from the repository getList function and you may see this function (the one that appears in your post) mentions attributeJoinProcessor and so on.. these lines aggregate to the collection various additional values - amongst them are extension_attributes - but more simply the product data that are setup to be part of this repository getList call.

Instead, the collection is just the product collection that you can create independently to the repository. Using the collection can be useful in many circumstances (particularly to write complex custom query). Now, of course all the extension_attributes won't appear in the collection unless you make some complex joins yourself.

Hope this gives you enough background to see why your result do differ

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.