diff --git a/classes/collection/OfferCollection.php b/classes/collection/OfferCollection.php index 1ab8980e..a633d8b4 100644 --- a/classes/collection/OfferCollection.php +++ b/classes/collection/OfferCollection.php @@ -15,6 +15,9 @@ * @method $this filterByDiscount() * @method $this filterByQuantity() * @method $this filterByProperty(array $arFilterList, \Lovata\FilterShopaholic\Classes\Collection\FilterPropertyCollection $obPropertyList) + * + * Digital products for Shopaholic + * @method $this sortByPeriod() */ class OfferCollection extends ElementCollection { diff --git a/classes/console/CheckTableIntegrity.php b/classes/console/CheckTableIntegrity.php index e7ac2c8a..4047debf 100644 --- a/classes/console/CheckTableIntegrity.php +++ b/classes/console/CheckTableIntegrity.php @@ -37,8 +37,12 @@ public function handle() { foreach ($this->arMigrationList as $arMigrationData) { $sClassName = $arMigrationData['class']; - $sFilePath = $arMigrationData['path']; - include_once base_path($sFilePath); + $sFilePath = base_path($arMigrationData['path']); + if (!file_exists($sFilePath)) { + continue; + } + + include_once $sFilePath; if (!class_exists($sClassName)) { continue; diff --git a/classes/helper/PriceTypeHelper.php b/classes/helper/PriceTypeHelper.php index 7e576a9b..e6551ca1 100644 --- a/classes/helper/PriceTypeHelper.php +++ b/classes/helper/PriceTypeHelper.php @@ -23,7 +23,7 @@ class PriceTypeHelper protected $sActivePriceTypeCode; /** - * Get value of active currency + * Get value of active price type * @param string $sPriceTypeCode * @return PriceType */ @@ -35,7 +35,7 @@ public function findByCode($sPriceTypeCode) } /** - * Get value of active currency + * Get value of active price type * @return PriceType */ public function getActive() @@ -44,7 +44,7 @@ public function getActive() } /** - * Get active currency code + * Get active price type code * @return null|string */ public function getActivePriceTypeCode() @@ -57,6 +57,20 @@ public function getActivePriceTypeCode() return $obPriceType->code; } + /** + * Get active price type code + * @return null|string + */ + public function getActivePriceTypeID() + { + $obPriceType = $this->getActive(); + if (empty($obPriceType)) { + return null; + } + + return $obPriceType->id; + } + /** * Clear active currency value * @param string $sPriceTypeCode @@ -69,7 +83,7 @@ public function switchActive($sPriceTypeCode) } /** - * Init currency data + * Init price type data */ protected function init() { @@ -79,7 +93,7 @@ protected function init() } /** - * Get active currency code and find active currency object by code + * Get active price type code and find active price type object by code */ protected function initActivePriceType() { diff --git a/classes/import/ImportCategoryModelFromXML.php b/classes/import/ImportCategoryModelFromXML.php index 279ce3d9..d047830f 100644 --- a/classes/import/ImportCategoryModelFromXML.php +++ b/classes/import/ImportCategoryModelFromXML.php @@ -108,9 +108,9 @@ protected function processModelObject() $this->importPreviewImage(); $this->importImageList(); - $this->importChildrenCategoryList(); - parent::processModelObject(); + + $this->importChildrenCategoryList(); } /** diff --git a/classes/item/CategoryItem.php b/classes/item/CategoryItem.php index 30fa3078..481097d1 100644 --- a/classes/item/CategoryItem.php +++ b/classes/item/CategoryItem.php @@ -54,6 +54,9 @@ * Filter for Shopaholic * @property \Lovata\FilterShopaholic\Classes\Collection\FilterPropertyCollection|\Lovata\PropertiesShopaholic\Classes\Item\PropertyItem[] $product_filter_property * @property \Lovata\FilterShopaholic\Classes\Collection\FilterPropertyCollection|\Lovata\PropertiesShopaholic\Classes\Item\PropertyItem[] $offer_filter_property + * + * VKontakte for Shopaholic + * @property int $category_vk_id */ class CategoryItem extends ElementItem { diff --git a/classes/item/OfferItem.php b/classes/item/OfferItem.php index 26de0762..2bf2b0ef 100644 --- a/classes/item/OfferItem.php +++ b/classes/item/OfferItem.php @@ -7,6 +7,7 @@ use Lovata\Shopaholic\Models\Offer; use Lovata\Shopaholic\Classes\Helper\TaxHelper; use Lovata\Shopaholic\Classes\Helper\CurrencyHelper; +use Lovata\Shopaholic\Classes\Helper\PriceTypeHelper; /** * Class OfferItem @@ -72,6 +73,22 @@ * @property int $discount_id * @property float $discount_value * @property string $discount_type + * + * Digital products for Shopaholic + * @property int $digital_product_period_id + * @property \Lovata\DigitalProductsShopaholic\Classes\Item\DigitalProductPeriodItem $digital_product_period + * + * YandexMarket for Shopaholic + * @property \System\Models\File $preview_image_yandex + * @property \October\Rain\Database\Collection|\System\Models\File[] $images_yandex + * + * Facebook for Shopaholic + * @property \System\Models\File $preview_image_facebook + * @property \October\Rain\Database\Collection|\System\Models\File[] $images_facebook + * + * VKontakte for Shopaholic + * @property \System\Models\File $preview_image_vkontakte + * @property \October\Rain\Database\Collection|\System\Models\File[] $images_vkontakte */ class OfferItem extends ElementItem { @@ -146,6 +163,10 @@ public function setActiveCurrency($sActiveCurrencyCode) */ public function getActivePriceType() { + if (empty($this->iActivePriceType)) { + $this->iActivePriceType = PriceTypeHelper::instance()->getActivePriceTypeID(); + } + return $this->iActivePriceType; } @@ -176,10 +197,11 @@ protected function setElementObject() */ protected function getPriceValueAttribute() { - if (empty($this->iActivePriceType)) { + $iActivePriceType = $this->getActivePriceType(); + if (empty($iActivePriceType)) { $fPrice = $this->getAttribute('price_value'); } else { - $fPrice = array_get($this->price_list, $this->iActivePriceType.'.price'); + $fPrice = array_get($this->price_list, $iActivePriceType.'.price'); } $fPrice = CurrencyHelper::instance()->convert($fPrice, $this->getActiveCurrency()); @@ -193,10 +215,11 @@ protected function getPriceValueAttribute() */ protected function getOldPriceValueAttribute() { - if (empty($this->iActivePriceType)) { + $iActivePriceType = $this->getActivePriceType(); + if (empty($iActivePriceType)) { $fPrice = $this->getAttribute('old_price_value'); } else { - $fPrice = array_get($this->price_list, $this->iActivePriceType.'.old_price'); + $fPrice = array_get($this->price_list, $iActivePriceType.'.old_price'); } $fPrice = CurrencyHelper::instance()->convert($fPrice, $this->getActiveCurrency()); diff --git a/classes/item/ProductItem.php b/classes/item/ProductItem.php index 6bcf472a..4ab85edb 100644 --- a/classes/item/ProductItem.php +++ b/classes/item/ProductItem.php @@ -67,6 +67,20 @@ * * Wish list for Shopaholic * @method bool inWishList() + * + * YandexMarket for Shopaholic + * @property \System\Models\File $preview_image_yandex + * @property \October\Rain\Database\Collection|\System\Models\File[] $images_yandex + * + * Facebook for Shopaholic + * @property \System\Models\File $preview_image_facebook + * @property \October\Rain\Database\Collection|\System\Models\File[] $images_facebook + * + * VKontakte for Shopaholic + * @property bool $active_vk + * @property int $external_vk_id + * @property \System\Models\File $preview_image_vkontakte + * @property \October\Rain\Database\Collection|\System\Models\File[] $images_vkontakte */ class ProductItem extends ElementItem { diff --git a/models/Category.php b/models/Category.php index ca4d1b8f..5d4abbb1 100644 --- a/models/Category.php +++ b/models/Category.php @@ -76,6 +76,9 @@ * Campaign for Shopaholic * @property \October\Rain\Database\Collection|\Lovata\CampaignsShopaholic\Models\Campaign[] $campaign * @method static \October\Rain\Database\Relations\BelongsToMany|\Lovata\CampaignsShopaholic\Models\Campaign campaign() + * + * VKontakte for Shopaholic + * @property int $category_vk_id */ class Category extends ImportModel { diff --git a/models/Offer.php b/models/Offer.php index 42925d8b..55138fab 100644 --- a/models/Offer.php +++ b/models/Offer.php @@ -90,6 +90,23 @@ * Campaign for Shopaholic * @property \October\Rain\Database\Collection|\Lovata\CampaignsShopaholic\Models\Campaign[] $campaign * @method static \October\Rain\Database\Relations\BelongsToMany|\Lovata\CampaignsShopaholic\Models\Campaign campaign() + * + * Digital product for Shopaholic + * @property int $digital_product_period_id + * @property \Lovata\DigitalProductsShopaholic\Models\DigitalProductPeriod $digital_product_period + * @method static \October\Rain\Database\Relations\BelongsTo|\Lovata\DigitalProductsShopaholic\Models\DigitalProductPeriod digital_product_period() + * + * YandexMarket for Shopaholic + * @property \System\Models\File $preview_image_yandex + * @property \October\Rain\Database\Collection|\System\Models\File[] $images_yandex + * + * Facebook for Shopaholic + * @property \System\Models\File $preview_image_facebook + * @property \October\Rain\Database\Collection|\System\Models\File[] $images_facebook + * + * VKontakte for Shopaholic + * @property \System\Models\File $preview_image_vkontakte + * @property \October\Rain\Database\Collection|\System\Models\File[] $images_vkontakte */ class Offer extends ImportModel { @@ -242,7 +259,7 @@ public function afterSave() /** * Set quantity attribute value - * @param int $iQuantity + * @param int $iQuantity */ public function setQuantityAttribute($iQuantity) { diff --git a/models/Product.php b/models/Product.php index 33298093..de5a51c4 100644 --- a/models/Product.php +++ b/models/Product.php @@ -25,81 +25,101 @@ * @mixin \October\Rain\Database\Builder * @mixin \Eloquent * - * @property $id - * @property bool $active - * @property string $name - * @property string $slug - * @property string $code - * @property int $category_id - * @property int $brand_id - * @property string $external_id - * @property string $preview_text - * @property string $description - * @property \October\Rain\Argon\Argon $created_at - * @property \October\Rain\Argon\Argon $updated_at - * @property \October\Rain\Argon\Argon $deleted_at + * @property $id + * @property bool $active + * @property string $name + * @property string $slug + * @property string $code + * @property int $category_id + * @property int $brand_id + * @property string $external_id + * @property string $preview_text + * @property string $description + * @property \October\Rain\Argon\Argon $created_at + * @property \October\Rain\Argon\Argon $updated_at + * @property \October\Rain\Argon\Argon $deleted_at * * Relations - * @property \System\Models\File $preview_image - * @property \October\Rain\Database\Collection|\System\Models\File[] $images + * @property \System\Models\File $preview_image + * @property \October\Rain\Database\Collection|\System\Models\File[] $images * - * @property Category $category + * @property Category $category * @method static \October\Rain\Database\Relations\BelongsTo|Category category() * - * @property \October\Rain\Database\Collection|Category[] $additional_category + * @property \October\Rain\Database\Collection|Category[] $additional_category * @method static \October\Rain\Database\Relations\BelongsToMany|Category additional_category() * - * @property Brand $brand + * @property Brand $brand * @method static \October\Rain\Database\Relations\BelongsTo|Brand brand() * - * @property \October\Rain\Database\Collection|Offer[] $offer + * @property \October\Rain\Database\Collection|Offer[] $offer * @method \October\Rain\Database\Relations\HasMany|Offer offer() * * @method static $this getByBrand(int $iBrandID) * * Properties for Shopaholic * @see \Lovata\PropertiesShopaholic\Classes\Event\ProductModelHandler::addPropertyMethods - * @property array $property + * @property array $property * * @property \October\Rain\Database\Collection|\Lovata\PropertiesShopaholic\Models\PropertyValueLink[] $property_value * @method static \October\Rain\Database\Relations\MorphMany|\Lovata\PropertiesShopaholic\Models\PropertyValueLink property_value() * * Popularity for Shopaholic - * @property int $popularity + * @property int $popularity * * Reviews for Shopaholic - * @property float $rating - * @property array $rating_data - * @property \October\Rain\Database\Collection|\Lovata\ReviewsShopaholic\Models\Review[] $review + * @property float $rating + * @property array $rating_data + * @property \October\Rain\Database\Collection|\Lovata\ReviewsShopaholic\Models\Review[] $review * @method static \October\Rain\Database\Relations\HasMany|\Lovata\ReviewsShopaholic\Models\Review review() * * Related products for Shopaholic - * @property \October\Rain\Database\Collection|Product[] $related + * @property \October\Rain\Database\Collection|Product[] $related * @method static \October\Rain\Database\Relations\BelongsToMany|$this related() * * Accessories for Shopaholic - * @property \October\Rain\Database\Collection|Product[] $accessory + * @property \October\Rain\Database\Collection|Product[] $accessory * @method static \October\Rain\Database\Relations\BelongsToMany|$this accessory() * * Search for Shopaholic, Sphinx for Shopaholic - * @property string $search_synonym - * @property string $search_content + * @property string $search_synonym + * @property string $search_content * * Discounts for Shopaholic - * @property \October\Rain\Database\Collection|\Lovata\DiscountsShopaholic\Models\Discount[] $discount + * @property \October\Rain\Database\Collection|\Lovata\DiscountsShopaholic\Models\Discount[] $discount * @method static \October\Rain\Database\Relations\BelongsToMany|\Lovata\DiscountsShopaholic\Models\Discount discount() * * Coupons for Shopaholic - * @property \October\Rain\Database\Collection|\Lovata\CouponsShopaholic\Models\CouponGroup[] $coupon_group + * @property \October\Rain\Database\Collection|\Lovata\CouponsShopaholic\Models\CouponGroup[] $coupon_group * @method static \October\Rain\Database\Relations\BelongsToMany|\Lovata\CouponsShopaholic\Models\CouponGroup coupon_group() * * Campaign for Shopaholic - * @property \October\Rain\Database\Collection|\Lovata\CampaignsShopaholic\Models\Campaign[] $campaign + * @property \October\Rain\Database\Collection|\Lovata\CampaignsShopaholic\Models\Campaign[] $campaign * @method static \October\Rain\Database\Relations\BelongsToMany|\Lovata\CampaignsShopaholic\Models\Campaign campaign() * * Labels for Shopaholic - * @property \October\Rain\Database\Collection|\Lovata\LabelsShopaholic\Models\Label[] $label + * @property \October\Rain\Database\Collection|\Lovata\LabelsShopaholic\Models\Label[] $label * @method static \October\Rain\Database\Relations\BelongsToMany|\Lovata\LabelsShopaholic\Models\Label label() + * + * Digital products for Shopaholic + * @property bool $is_digital_product + * + * YandexMarket for Shopaholic + * @property \System\Models\File $preview_image_yandex + * @property \October\Rain\Database\Collection|\System\Models\File[] $images_yandex + * + * Facebook for Shopaholic + * @property \System\Models\File $preview_image_facebook + * @property \October\Rain\Database\Collection|\System\Models\File[] $images_facebook + * + * VKontakte for Shopaholic + * @property bool $active_vk + * @property int $external_vk_id + * @property \System\Models\File $preview_image_vkontakte + * @property \October\Rain\Database\Collection|\System\Models\File[] $images_vkontakte + * @method static $this activeVK() + * @method static $this notActiveVK() + * @method static $this isNotEmptyExternalVkId() */ class Product extends ImportModel { @@ -148,9 +168,9 @@ class Product extends ImportModel public $belongsToMany = [ 'additional_category' => [ Category::class, - 'table' => 'lovata_shopaholic_additional_categories', + 'table' => 'lovata_shopaholic_additional_categories', ], - 'promo_block' => [ + 'promo_block' => [ PromoBlock::class, 'table' => 'lovata_shopaholic_promo_block_relation', 'otherKey' => 'promo_id', @@ -219,7 +239,7 @@ public function scopeGetByCategories($obQuery, $sData) { if (!empty($sData)) { foreach ($sData as $category) { - $obQuery->orWhere('category_id', $category)->orWhereHas('additional_category', function($obQuery) use ($category) { + $obQuery->orWhere('category_id', $category)->orWhereHas('additional_category', function ($obQuery) use ($category) { $obQuery->where('category_id', $category); }); } diff --git a/updates/version.yaml b/updates/version.yaml index ec2d0626..6d423887 100644 --- a/updates/version.yaml +++ b/updates/version.yaml @@ -101,4 +101,6 @@ 1.22.4: - 'Removed deleted offers from sorting by price.' 1.22.5: - - 'Fixed bug with deactivating items in import from XML files.' \ No newline at end of file + - 'Fixed bug with deactivating items in import from XML files.' +1.23.0: + - 'Added ability to show catalog with active price type. Added annotations for integration with Digital product for Shopaholic plugin.' \ No newline at end of file