Skip to content

Commit

Permalink
FIX: Images Cover Flag
Browse files Browse the repository at this point in the history
ADD: Product Show Price Flag
  • Loading branch information
BadPixxel committed May 23, 2024
1 parent cf24157 commit 983a378
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
23 changes: 23 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
################################################################################
#
# * This file is part of BadPixxel ProductMixer Module.
# *
# * Copyright (C) BadPixxel <www.badpixxel.com>
# *
# * This program is free software: you can redistribute it
# * and/or modify it under the terms of the GNU General Public License
# * as published by the Free Software Foundation, version 3.
# *
# * This program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# * See the GNU General Public License for more details.
# *
# * You should have received a copy of the GNU General Public License
# * long with this program. If not, see <https://www.gnu.org/licenses/>.
#
################################################################################

###> badpixxel/wall-e ###
GRUMPHP_BIN="modules/splashsync/vendor/bin/grumphp"
###< badpixxel/wall-e ###
15 changes: 9 additions & 6 deletions modules/splashsync/src/Objects/Product/ImagesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,11 @@ private function updateImageCoverFlag(Image &$psImage, array $imgArray): void
if ($psImage->cover !== $isCover) {
$psImage->cover = $isCover;
$this->needUpdate("Image");
//====================================================================//
// Delete Cover Flag for Other Images
if ($isCover) {
Image::deleteCover($psImage->id_product);
}
}
}

Expand Down Expand Up @@ -594,6 +599,7 @@ private function updateImgThumbnail(): void
if (!file_exists($imagePath.'.jpg')) {
continue;
}

foreach (ImageType::getImagesTypes("products") as $imageType) {
$imgThumb = _PS_PROD_IMG_DIR_.$imageObj->getExistingImgPath();
$imgThumb .= '-'.Tools::stripslashes($imageType['name']).'.jpg';
Expand Down Expand Up @@ -699,13 +705,12 @@ private function setImgArray(array $data): bool
//====================================================================//
// Search For Image In Current List
$psImage = $this->searchImage($value["image"]["md5"]);
if (false == $psImage) {
if (!$psImage) {
//====================================================================//
// If Not found, Add this object to list
$psImage = $this->addImageToProduct(
$inImage,
(int) $this->getImagePosition($value),
(bool) $this->getImageCoverFlag($value)
(int) $this->getImagePosition($value)
);
}
//====================================================================//
Expand Down Expand Up @@ -752,11 +757,10 @@ private function setImgArray(array $data): bool
*
* @param array $imgArray Splash Image Definition Array
* @param int $position Image Position (On Base Product Sheet)
* @param bool $isCover Image is Cover Image
*
* @return false|Image
*/
private function addImageToProduct(array $imgArray, int $position, bool $isCover)
private function addImageToProduct(array $imgArray, int $position)
{
//====================================================================//
// Read File from Splash Server
Expand All @@ -773,7 +777,6 @@ private function addImageToProduct(array $imgArray, int $position, bool $isCover
$objectImage->legend = $newImageFile["name"] ?? $newImageFile["filename"];
$objectImage->id_product = $this->ProductId;
$objectImage->position = $position;
$objectImage->cover = $isCover;
//====================================================================//
// Write Image To Database
if (!$objectImage->add()) {
Expand Down
9 changes: 9 additions & 0 deletions modules/splashsync/src/Objects/Product/MetaTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ protected function buildMetaFields(): void
->microData("http://schema.org/Product", "onsale")
;
//====================================================================//
// Display Price
$this->fieldsFactory()->create(SPL_T_BOOL)
->identifier("show_price")
->name($this->spl->l("Show Price"))
->microData("http://schema.org/Product", "showPrice")
;
//====================================================================//
// Online Only
$this->fieldsFactory()->create(SPL_T_BOOL)
->identifier("online_only")
Expand Down Expand Up @@ -103,6 +110,7 @@ protected function getMetaFields(string $key, string $fieldName): void
// OTHERS INFORMATIONS
//====================================================================//
case 'active':
case 'show_price':
case 'on_sale':
case 'online_only':
$this->getSimpleBool($fieldName);
Expand Down Expand Up @@ -188,6 +196,7 @@ protected function setMetaFields(string $fieldName, $fieldData): void
//====================================================================//
// Direct Writings
case 'active':
case 'show_price':
case 'on_sale':
case 'online_only':
$this->setSimple($fieldName, $fieldData);
Expand Down

0 comments on commit 983a378

Please sign in to comment.