Open xi-ao opened 3 weeks ago
Sorry, the API endpoint does not exist in the module, we added it to be able to get offers but the URL I gave is not native. You need to add this in a webapi.xml
to make it work:
<route url="/V1/retaileroffer/list" method="GET">
<service class="Smile\Offer\Api\OfferRepositoryInterface" method="getList"/>
<resources>
<resource ref="Smile_RetailerOffer::retailer_offers"/>
</resources>
</route>
Anyway, the bug still applies.
The easiest fix here would be to remove this useless
Smile\Offer\Api\Data\OfferSearchResultsInterface
and directly useMagento\Framework\Api\SearchResults
in both the interface and the class.
Actually no, that won't be a fix but rather a new bug, because in this case the API call would return empty objects instead of the items' data.
So I guess the proper fix would be to create a new Smile\Offer\Model\OfferSearchResults
and update di.xml
accordingly.
Preconditions
Magento Version : EE 2.4.7-p2
Module Offer Version : 2.0.1
Environment : Developer/Production
PHP 8.3
Steps to reproduce
/V1/retaileroffer/list?searchCriteria[pageSize]=2
Actual result
The following error shows up:
The reason is simple: the
di.xml
specifieshttps://github.com/Smile-SA/magento2-module-offer/blob/ba0e1a73376056dc745f75fd8cdcc613325f2161/etc/di.xml#L4
while the method's signature is
https://github.com/Smile-SA/magento2-module-offer/blob/ba0e1a73376056dc745f75fd8cdcc613325f2161/Api/OfferRepositoryInterface.php#L33-L40
but
OfferSearchResultsInterface
is not a subclass ofSearchResults
.The easiest fix here would be to remove this useless
Smile\Offer\Api\Data\OfferSearchResultsInterface
and directly useMagento\Framework\Api\SearchResults
in both the interface and the class.