Files
ltsecurityinc/app/code/JR/NetSuite/Mapper/ProductMapper.php
T

64 lines
2.0 KiB
PHP
Executable File

<?php
namespace JR\NetSuite\Mapper;
use JR\NetSuite\Mapper\AbstractMapper;
// Handles the specifics of mapping product data.
class ProductMapper {
/**
* ProductMapper constructor.
*/
public function __construct(
) {
}
/**
* Convert data from NetSuite format to Magento format.
*
* @param array $netSuiteData
* @return array
*/
public function convertToMagentoFormat($netSuiteData) {
// convert netsuite data to magento data
$magentoData = [];
foreach($netSuiteData as $data) {
$magentoData[] = [
'netsuite_product_id' => $data['internalid'],
'sku' => $data['itemid'],
// 'type' => $data['includechildren'] ? 'configurable' : 'simple',
// 'category' => $data['category'],
'name' => $data['displayname'] == '' ? $data['itemid'] : $data['displayname'],
'description' => $data['salesdescription'],
'status' => $data['isinactive'],
// 'vendor' => $data['vendor'],
// 'manufacturer' => $data['manufacturer'],
'upc' => $data['upccode'],
// 'mpn' => $data['mpn'],
// 'tax_class' => $data['taxschedule'],
'weight' => $data['weight'] ?? 1,
// 'weight_unit' => $data['weightunit'],
// 'cost' => $data['cost'],
'price' => $data['baseprice'] != '' ? $data['baseprice'] : 0,
'qty' => (int) ($data['locationquantityavailable'] ?? $data['quantityavailable'] ?? 0),
'locationId' => $data['inventorylocation'] ?? '',
'custitem_item_eol_for_sales' => $data['custitem_item_eol_for_sales'] ?? false,
// 'is_in_stock' => ($data['quantityavailable'] ?? 0) > 0 ? 1 : 0,
// 'created_at' => $data['createddate'],
// 'updated_at' => $data['lastmodifieddate']
];
}
return $magentoData;
}
/**
* Convert data from Magento format to NetSuite format.
*
* @param array $magentoData
* @return array
*/
public function convertToNetSuiteFormat($magentoData) {
// Your conversion logic here
}
}