Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AB auction view - direct link to product and show articlenumber - Update WriteOrdersService.php #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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: 24 additions & 2 deletions Services/WriteData/External/WriteOrdersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,34 @@ public function transform(array $data) {
$mainNumber = preg_replace('~\D~', '', $position->getInternalIdentifier());
}

/* ************************************************
$directShopLink
0 default (old / default behavior up to Aferbuy Connector v.1.0.3)
1 for direct link with article number in afterbuy auction overview

ToDo:
- include variable to plugin config screen or modify sourcecode (fixed) if old method / value is not needed anymore.
- find a better (more secure) way to read the shop URL. Maybe from Shopware config and optional with subfolder, if shop is not in the root directory.
- optional - not needed but maybe a little bit better - replace the whole article_link with the exact string read and generated from the article directly. - maybe a more optimized way.
************************************************ */
$directShopLink = 1;

if ($directShopLink == 1)
// $mainNumber = $position->getInternalIdentifier(); // Shopware article number - removed 2020-12-09 because if not numeric, AB-Response is not successful. Need to be numeric value for afterbuy.
$mainNumber = preg_replace('/[^0-9]/', '', $position->getInternalIdentifier()); // Shopware article number (with replaces all which is not numeric)

if(empty($mainNumber)) {
$mainNumber = 0;
}

$orders[$internalIdentifyer]['Artikelnr_' . $i] = $mainNumber;
$orders[$internalIdentifyer]['Artikelnr1_' . $i] = $position->getExternalIdentifier();
if ($directShopLink == 1) {
$orders[$internalIdentifyer]['Artikelnr1_' . $i] = $position->getInternalIdentifier(); // Shopware article number
$websiteUrl = 'https://' . $_SERVER['SERVER_NAME']; // read Shop URL - better replace with shopURL from Shopware config...
$orders[$internalIdentifyer]['ArtikelLink_' . $i] = $websiteUrl . '/search?sSearch=' . $position->getInternalIdentifier(); // direct Link to the shop article
} else {
$orders[$internalIdentifyer]['Artikelnr1_' . $i] = $position->getExternalIdentifier(); // Shopware EAN (old method / value)
}

$orders[$internalIdentifyer]['ArtikelStammID_' . $i] = $position->getInternalIdentifier();

Expand Down Expand Up @@ -184,4 +206,4 @@ public function send($targetData) {
return $submitted;

}
}
}