Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion Model/Adapter/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,30 @@ protected function addFieldHandlers()

try {

//Add id fieldhandler
$this->addFieldHandler('id', function ($item) {
try {
/**
* @var \Magento\Catalog\Model\Product $item
*/
return intval($item->getId());
} catch (\Exception $e) {
return 0;
}
});

//Add description fieldhandler
$this->addFieldHandler('description', function ($item) {
try {
/**
* @var \Magento\Catalog\Model\Product $item
*/
return strip_tags($item->getDescription());
} catch (\Exception $e) {
return '';
}
});

//Add price fieldhandler
$this->addFieldHandler('price', function ($item) {
try {
Expand Down Expand Up @@ -229,7 +253,7 @@ protected function addFieldHandlers()

//Add categories fieldhandler
$this->addFieldHandler('categories', function ($item) {
return $item->getCategoryIds();
return array_map('intval', $item->getCategoryIds());
});

//Add age fieldhandler
Expand Down
2 changes: 1 addition & 1 deletion Model/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private function post($endpoint, $params = [])
/** @var \Magento\Framework\HTTP\ZendClient $httpClient */
$httpClient = $this->httpClientFactory->create();
$httpClient->setUri($this->baseurl . $endpoint);
$httpClient->setRawData(json_encode($params), 'application/json');
$httpClient->setRawData(json_encode($params, JSON_NUMERIC_CHECK), 'application/json');

$result = $httpClient->request('POST');

Expand Down