Skip to content

Commit

Permalink
Merge branch 'beta' into perf/TW-13-grumphp-issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jansentjeu committed Mar 15, 2024
2 parents 8ac3926 + fb6a144 commit c2a9ec0
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 10 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
push:
branches:
- master
- beta

jobs:
release:
runs-on: ubuntu-latest

permissions:
contents: write

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout Git repository
uses: actions/checkout@v3

- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20

- name: Install semantic-release
run: npm install -g semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/exec

- name: Run semantic-release
run: semantic-release
31 changes: 31 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"branches": [
{
"name": "master"
},
{
"name": "beta",
"prerelease": true
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}
4 changes: 2 additions & 2 deletions Model/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Magento\Framework\Profiler;
use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Model\StoreManagerInterface;
use Zend\Http\Client as HttpClient;
use Laminas\Http\Client as HttpClient;

/**
* Class Export
Expand Down Expand Up @@ -280,7 +280,7 @@ protected function triggerTweakwiseImport($store = null, $type = null): void
$client = new HttpClient($apiImportUrl);
$client->send();
$this->log->debug('TW import triggered');
} catch (HttpClient\Exception\ExceptionInterface $e) {
} catch (Exception $e) {
$this->log->error(sprintf('Trigger TW import failed due to %s', $e->getMessage()));
}
}
Expand Down
15 changes: 13 additions & 2 deletions Model/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Exception;
use Psr\Log\LoggerInterface;
use Magento\Framework\App\State;

/**
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
Expand All @@ -22,14 +23,22 @@ class Logger implements LoggerInterface
*/
protected $log;

/**
* @var bool
*/
public bool $enableDebugLog;

/**
* Log constructor.
*
* @param LoggerInterface $log
* @param State $state
*/
public function __construct(LoggerInterface $log)
public function __construct(LoggerInterface $log, State $state)
{
$this->log = $log;

$this->enableDebugLog = ($state->getMode() !== State::MODE_PRODUCTION);
}

/**
Expand Down Expand Up @@ -93,7 +102,9 @@ public function info($message, array $context = [])
*/
public function debug($message, array $context = [])
{
$this->log->debug('[TweakWise] ' . $message, $context);
if ($this->enableDebugLog) {
$this->log->debug('[TweakWise] ' . $message, $context);
}
}

/**
Expand Down
7 changes: 3 additions & 4 deletions Model/Write/Products/CollectionDecorator/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function decorate(Collection|PriceCollection $collection): void
while ($row = $priceQuery->fetch()) {
$entityId = $row['entity_id'];
$row['currency'] = $currency->getCurrencyCode();
$row['price'] = $this->getPriceValue($collection->getStore()->getId(), $row);
$row['price'] = $this->getPriceValue($row, $priceFields);

//do all prices * exchange rate
foreach ($priceFields as $priceField) {
Expand Down Expand Up @@ -105,13 +105,12 @@ protected function createPriceSelect(array $ids, int $websiteId): ProductCollect
}

/**
* @param int $storeId
* @param array $priceData
* @param array $priceFields
* @return float
*/
protected function getPriceValue(int $storeId, array $priceData): float
protected function getPriceValue(array $priceData, array $priceFields): float
{
$priceFields = $this->config->getPriceFields($storeId);
foreach ($priceFields as $field) {
$value = isset($priceData[$field]) ? (float)$priceData[$field] : 0;
if ($value > 0.00001) {
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,7 @@ https://yoursite.com/tweakwise/feed/export/key/{{feed_key}}/store/storecode //st
Magento has multiple visibility settings, tweakwise only knows visible products meaning that if a product is in the feed then it will be visible while navigating and searching.
The magento visibility setting is exported in the feed so you can add a hidden filter to your tweakwise template to artificially use the correct settings.
If you do this then exclude the visibility attribute from child products (see "Export Settings").
## Contributors
If you want to create a pull request as a contributor, use the guidelines of semantic-release. semantic-release automates the whole package release workflow including: determining the next version number, generating the release notes, and publishing the package.
By adhering to the commit message format, a release is automatically created with the commit messages as release notes. Follow the guidelines as described in: https://github.com/semantic-release/semantic-release?tab=readme-ov-file#commit-message-format.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.0 <8.3"
"php": ">=8.0 <8.3",
"laminas/laminas-http": "^2.15.0"
},
"require-dev": {
"bitexpert/phpstan-magento": "^0.30.1",
Expand Down
2 changes: 1 addition & 1 deletion etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<resource>Tweakwise_Magento2TweakwiseExport::config</resource>
<group id="export" translate="label" type="text" sortOrder="1000" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Export</label>
<comment>Tweakwise Export version v6.0.1</comment>
<comment>Tweakwise Export version v6.0.2</comment>
<field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
Expand Down

0 comments on commit c2a9ec0

Please sign in to comment.