Skip to content

Commit

Permalink
ST-2943: provide supplier information in single product endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniocosentino committed Mar 30, 2021
1 parent 5d87ced commit 9bb2612
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### v5.7.3 2021-03-30
* Provide brand (supplier) information in single product endpoint

### v5.7.2 2020-07-07
* Use proper parameters for prepared sql statements

Expand Down
2 changes: 1 addition & 1 deletion StylaSEO/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function getLabel()

public function getVersion()
{
return '5.7.2';
return '5.7.3';
}

public function getInfo()
Expand Down
9 changes: 9 additions & 0 deletions StylaSEO/Controllers/Frontend/Stylaapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ public function getCurrency()
return $shop->getCurrency()->toArray();
}

public function getSupplier( $productId )
{
$query = "SELECT b.name FROM `s_articles` a LEFT JOIN `s_articles_supplier` b ON a.supplierID = b.id WHERE a.id = $productId";
$supplier = Shopware()->Db()->fetchRow( $query );
return $supplier['name'];
}

public function throwErr($error)
{
$message['error'] = $error;
Expand Down Expand Up @@ -309,6 +316,7 @@ public function productAction()
$ekPrices = $this->getEKPrices($article['mainDetail'], $currencyInfo);
$productEKPrice = $ekPrices['price'];
$productEKPseudoPrice = $ekPrices['pseudoPrice'];
$supplierName = $this->getSupplier( $id );

/*
This point will be undefined behavior if no EK price exists.
Expand Down Expand Up @@ -350,6 +358,7 @@ public function productAction()
'id' => $article['mainDetail']['number'],
'name' => htmlentities($article['name']),
'description' => $article['description'],
'brand' => $supplierName,
'categories' => array_column($article['categories'], 'id'),
'saleable' => ($isActive && ($hasStock || !$isLastStock)) ? 'true' : 'false',
'price' => $priceFormatted,
Expand Down
2 changes: 1 addition & 1 deletion docker/apache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RUN php -r "unlink('composer-setup.php');"

# Update dependencies of sw-cli-tools
WORKDIR /home/root/sw-cli-tools
RUN composer -n install
RUN composer -n install --ignore-platform-reqs

# Create symlink for sw-cli tools
RUN ln -s /home/root/sw-cli-tools/bin/sw /usr/bin/sw
Expand Down

0 comments on commit 9bb2612

Please sign in to comment.