diff --git a/Service/WebApi/Order.php b/Service/WebApi/Order.php index 567c5e3..0dbdfa4 100755 --- a/Service/WebApi/Order.php +++ b/Service/WebApi/Order.php @@ -136,7 +136,7 @@ private function getCollection( * * @return array|null */ - private function getProfileData($order): ?array + private function getProfileData(OrderModel $order): ?array { try { if ($order->getCustomerId()) { @@ -146,13 +146,24 @@ private function getProfileData($order): ?array 'email' => $customer->getEmail() ]; } else { - return [ + $data = [ 'id' => null, 'customer_firstname' => $order->getCustomerFirstname(), 'customer_middlename' => $order->getCustomerMiddlename(), 'customer_lastname' => $order->getCustomerLastname(), 'email' => $order->getCustomerEmail() ]; + if ($shipAddress = $order->getShippingAddress()) { + $data['region_id'] = $shipAddress->getRegionId(); + $data['region'] = $shipAddress->getRegion(); + $data['postcode'] = $shipAddress->getPostcode(); + $data['street'] = $shipAddress->getStreet(); + $data['city'] = $shipAddress->getCity(); + $data['telephone'] = $shipAddress->getTelephone(); + $data['country_id'] = $shipAddress->getCountryId(); + $data['company'] = $shipAddress->getCompany(); + } + return $data; } } catch (\Exception $exception) { return null; diff --git a/Service/WebApi/Product.php b/Service/WebApi/Product.php index d29c668..566c79e 100755 --- a/Service/WebApi/Product.php +++ b/Service/WebApi/Product.php @@ -252,17 +252,47 @@ private function applyFilter(Collection $products, array $filters, int $storeId } /** - * @param $product + * Get the main image URL for a product. * - * @return string + * @param \Magento\Catalog\Model\Product $product The product instance. + * @return string The full URL of the product's main image, or an empty string if no image exists. */ - private function getMainImage($product) + private function getMainImage($product): string + { + if ($image = $product->getImage()) { + return $this->getMediaBaseUrl($product->getStoreId()) + . 'catalog/product' + . $this->normalizeImagePath($image); + } + + return ''; + } + + /** + * Retrieve the base URL for media files for a specific store. + * + * @param int $storeId The store ID. + * @return string The base media URL for the store. + */ + private function getMediaBaseUrl(int $storeId): string { if (!$this->mediaPath) { - $this->mediaPath = $this->storeManager->getStore($product->getStoreId()) + $this->mediaPath = $this->storeManager->getStore($storeId) ->getBaseUrl(UrlInterface::URL_TYPE_MEDIA); } - return $this->mediaPath . 'catalog/product' . $product->getImage(); + + return $this->mediaPath; + } + + /** + * Normalize the image path by ensuring it starts with a forward slash. + * + * @param string $image The image path from the product. + * @return string The normalized image path. + */ + private function normalizeImagePath(string $image): string + { + return '/' . ltrim($image, '/'); } /** diff --git a/Service/WebApi/Profiles.php b/Service/WebApi/Profiles.php index 3aa9491..433637c 100755 --- a/Service/WebApi/Profiles.php +++ b/Service/WebApi/Profiles.php @@ -118,7 +118,7 @@ public function execute(int $storeId, array $extra = [], SearchCriteriaInterface "active" => true, "subscribed_to_newsletter" => $this->isSubscribed($customer), "birthdate" => $customer->getDob(), - "customer_group" => $customerGroups[$customer->getGroupId()] ?? '' + "eav_customer_group" => $customerGroups[$customer->getGroupId()] ?? '' ]; if ($billingId = $customer->getDefaultBilling()) { diff --git a/Service/WebApi/Variants.php b/Service/WebApi/Variants.php index e31a98f..8bdaebc 100755 --- a/Service/WebApi/Variants.php +++ b/Service/WebApi/Variants.php @@ -125,6 +125,7 @@ public function execute(int $storeId, array $extra = [], SearchCriteriaInterface "price_excl" => $product->getPrice(), "price_incl" => $product->getPrice(), "unit_price" => $product->getPrice(), + "special_price" => $product->getSpecialPrice(), "sku" => $this->getAttributeValue($product, $sku), "brand" => $this->getAttributeValue($product, $brand), "stock_level" => $this->getStockLevel($product, $stockData, $websiteId), diff --git a/composer.json b/composer.json index 4d26131..18653f3 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magmodules/magento2-reloadify", "description": "Reloadify extension for Magento 2", "type": "magento2-module", - "version": "1.11.0", + "version": "1.12.0", "license": [ "BSD-2-Clause" ], diff --git a/etc/config.xml b/etc/config.xml index 90fd9b6..be0640f 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -10,7 +10,7 @@ - v1.11.0 + v1.12.0 0 0