Skip to content

Commit 7ae619f

Browse files
Merge pull request #32 from magmodules/release/1.12.0
Release/1.12.0
2 parents e7d5bcf + 175ce81 commit 7ae619f

File tree

6 files changed

+52
-10
lines changed

6 files changed

+52
-10
lines changed

Service/WebApi/Order.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private function getCollection(
136136
*
137137
* @return array|null
138138
*/
139-
private function getProfileData($order): ?array
139+
private function getProfileData(OrderModel $order): ?array
140140
{
141141
try {
142142
if ($order->getCustomerId()) {
@@ -146,13 +146,24 @@ private function getProfileData($order): ?array
146146
'email' => $customer->getEmail()
147147
];
148148
} else {
149-
return [
149+
$data = [
150150
'id' => null,
151151
'customer_firstname' => $order->getCustomerFirstname(),
152152
'customer_middlename' => $order->getCustomerMiddlename(),
153153
'customer_lastname' => $order->getCustomerLastname(),
154154
'email' => $order->getCustomerEmail()
155155
];
156+
if ($shipAddress = $order->getShippingAddress()) {
157+
$data['region_id'] = $shipAddress->getRegionId();
158+
$data['region'] = $shipAddress->getRegion();
159+
$data['postcode'] = $shipAddress->getPostcode();
160+
$data['street'] = $shipAddress->getStreet();
161+
$data['city'] = $shipAddress->getCity();
162+
$data['telephone'] = $shipAddress->getTelephone();
163+
$data['country_id'] = $shipAddress->getCountryId();
164+
$data['company'] = $shipAddress->getCompany();
165+
}
166+
return $data;
156167
}
157168
} catch (\Exception $exception) {
158169
return null;

Service/WebApi/Product.php

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,17 +252,47 @@ private function applyFilter(Collection $products, array $filters, int $storeId
252252
}
253253

254254
/**
255-
* @param $product
255+
* Get the main image URL for a product.
256256
*
257-
* @return string
257+
* @param \Magento\Catalog\Model\Product $product The product instance.
258+
* @return string The full URL of the product's main image, or an empty string if no image exists.
258259
*/
259-
private function getMainImage($product)
260+
private function getMainImage($product): string
261+
{
262+
if ($image = $product->getImage()) {
263+
return $this->getMediaBaseUrl($product->getStoreId())
264+
. 'catalog/product'
265+
. $this->normalizeImagePath($image);
266+
}
267+
268+
return '';
269+
}
270+
271+
/**
272+
* Retrieve the base URL for media files for a specific store.
273+
*
274+
* @param int $storeId The store ID.
275+
* @return string The base media URL for the store.
276+
*/
277+
private function getMediaBaseUrl(int $storeId): string
260278
{
261279
if (!$this->mediaPath) {
262-
$this->mediaPath = $this->storeManager->getStore($product->getStoreId())
280+
$this->mediaPath = $this->storeManager->getStore($storeId)
263281
->getBaseUrl(UrlInterface::URL_TYPE_MEDIA);
264282
}
265-
return $this->mediaPath . 'catalog/product' . $product->getImage();
283+
284+
return $this->mediaPath;
285+
}
286+
287+
/**
288+
* Normalize the image path by ensuring it starts with a forward slash.
289+
*
290+
* @param string $image The image path from the product.
291+
* @return string The normalized image path.
292+
*/
293+
private function normalizeImagePath(string $image): string
294+
{
295+
return '/' . ltrim($image, '/');
266296
}
267297

268298
/**

Service/WebApi/Profiles.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function execute(int $storeId, array $extra = [], SearchCriteriaInterface
118118
"active" => true,
119119
"subscribed_to_newsletter" => $this->isSubscribed($customer),
120120
"birthdate" => $customer->getDob(),
121-
"customer_group" => $customerGroups[$customer->getGroupId()] ?? ''
121+
"eav_customer_group" => $customerGroups[$customer->getGroupId()] ?? ''
122122
];
123123

124124
if ($billingId = $customer->getDefaultBilling()) {

Service/WebApi/Variants.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public function execute(int $storeId, array $extra = [], SearchCriteriaInterface
125125
"price_excl" => $product->getPrice(),
126126
"price_incl" => $product->getPrice(),
127127
"unit_price" => $product->getPrice(),
128+
"special_price" => $product->getSpecialPrice(),
128129
"sku" => $this->getAttributeValue($product, $sku),
129130
"brand" => $this->getAttributeValue($product, $brand),
130131
"stock_level" => $this->getStockLevel($product, $stockData, $websiteId),

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magmodules/magento2-reloadify",
33
"description": "Reloadify extension for Magento 2",
44
"type": "magento2-module",
5-
"version": "1.11.0",
5+
"version": "1.12.0",
66
"license": [
77
"BSD-2-Clause"
88
],

etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<default>
1111
<magmodules_reloadify>
1212
<general>
13-
<version>v1.11.0</version>
13+
<version>v1.12.0</version>
1414
<enable>0</enable>
1515
<debug>0</debug>
1616
</general>

0 commit comments

Comments
 (0)