class ProductRepository extends EntityRepository implements AbstractBlockElementRepositoryInterface

Class ProductRepository is injected as alligator.product_repository service. ProductRepository is used for crud operation for managed entity.

Use this class to work with database.

Traits

Trait JQGridTrait
Class ProductSearchRepositoryTrait
Class AvailabilityChangeRepositoryTrait
Class ProductPriceForPricelistAndGroupTrait. Trait that is intended to be used in repositories that query product table and need to calcuate product price

Constants

ALIAS

Alias for product

PRODUCT_ATTRIBUTE_VALUES_ALIAS

Alias for product attribute values

PRODUCT_ATTRIBUTE_VALUES_FEATURES_ALIAS

Alias for product attribute values feature

ATTRIBUTE_VALUES_ALIAS

Alias for attribute values

BRAND_ALIAS

Alias for brand

PRICELIST_ITEMS_ALIAS

Alias for price list item

PRICELIST_ALIAS

Alias for price list

TRANSLATION_ALIAS

Alias for product translation

ATTRIBUTES

Alias for attribute

ATTRIBUTE_SET

Alias for attribute set

JOIN_WITH_SIMPLE_PRODUCT

Alias for simple product

JOIN_WITH_GROUP_PRODUCTS

Alias for group product join

JOIN_WITH_GROUP_SIMPLE_PRODUCTS

Alias for join group simple product

JOIN_WITH_PRICES

Alias for join with prices

JOIN_WITH_CATEGORY_ALIAS

Alias for join with category

JOIN_WITH_FEATURES

Alias for join with product feature

LIKE_WILDCARD

Wildcard

AVAILABLE_STATE

Product status available

PRODUCT_TABLE_NAME

Table name of product entity

SIMPLE_PRODUCT_TABLE_NAME

Table name of simple product entity

SP_QUANTITY_ROW

Simple product field (numberInStock)

SP_RESERVED_QUANTITY_ROW

Simple product field (reservedQuantity)

SP_TOTAL_QUANTITY_ROW

Simple product field (totalQuantity)

PRODUCT_SEARCH_FIELDS

List of product fields for search

PRODUCT_DEFAULT_SORT_FIELD

List of product fields for sort

SEARCH_COLUMNS

List of product properties for search

PRODUCTS_ON_ACTION_RESULTS_KEY

Key for caching products on action

Methods

jQGridJoinFields(QueryBuilder $qb, JQGridWrapper $jqGridWrapper)

All joins used in select.

jQGridGroupByFields(QueryBuilder $qb, JQGridWrapper $jqGridWrapper)

Should contain group by which jqgrid uses.

array
findAllForJQGRID(int $page, int $offset, array $sortParams, array $additionalParams, JQGridWrapper $jqGridWrapper)

JQGrid function

array
searchForJQGRID(array $searchParams, array $sortParams, bool $isCountSearch = false, array $additionalParams = array(), JQGridWrapper $jqGridWrapper = null)

JQGrid function

productLimitDataDQL(QueryBuilder $qb, array $limitData)

No description

string
productLimitDataSQL(string $productAlias, array $limitData, bool $addAnd = true)

No description

brandLimitDataDQL(QueryBuilder $qb, array $limitData, string $brandAlias = null)

No description

array
getCustomPriceData(ProductSearchWrapper $searchWrapper)

get sql algorithm to use use when calculating price, action price, field to select action price

array
doProductSearch(ProductSearchWrapper $searchWrapper)

No description

flushProducts(array|null $products = null)

Flush entity manager

save(PrimaryKeyInterface $entity)

Persist new product

edit(PrimaryKeyInterface $entity)

Merge product

EntityManager|EntityManagerInterface
getEM()

No description

array
findProductsOnAction(mixed $page, mixed $offset, array|null $limitData = null)

Find products on action with pagination

updateQty(Product $product)

Update product quantities on simple product for specific products

updateProductQtyAfterPAV(ProductAttributeValues $pav)

Update product quantities on simple product for specific product attribute values

getProductById(Product $product)

Find product by id

getProductByPrimaryKey(Product $entity)

Find product by id or slug

getProductForEdit(Product $entity)

Find product by id or slug

array
getGroupProductsFromDB(array $array)

Find collection of products

ArrayCollection
saveCSV(ArrayCollection $objectList, Category $dbCategory = null, AttributeSet $dbAttributeSet = null)

Persist new products from array with custom id generator

findByErpCode(string $code)

Find product by erp code

array
findMultipleByErpCode(array $arrayCodes)

Find products for provided array of ids

array
findAllProductErpCodeSearchString()

Find all product id, erpCode and productSearchString fields

array
getAttrValsForFilter(array $products)

Find all ids of attribute value, brand and category for provided array of products

getDBProductForProductPage(int $productId, array|null $limitData = null)

Find product by id

array
getProductQuickInformation(int $productId)

Find product information by id

getDBProductBySlugForProductPage(string $productSlug, array|null $limitData = null)

Find product by slug

array
getAllProductsFromArray(array $productsArray)

Find all product for provided array of ids

bool|stdClass
deleteMultiple(array $products)

Remove products from array

mixed
saveProductCollectionFromCMD(array $array, OutputInterface|null $output = null)

Persist collection of products

startTransaction()

Start db transaction

commitTransaction()

Commit db transaction

rollbackTransaction()

Rollback db transaction

bool
saveProductsFromArray(array $arrayOfProducts, OutputInterface|null $output = null)

Persist collecion of products

array
getProductsSlugsNoLocale()

Find all products slugs

mixed
getProductMetadata()

Get product metadata

mixed
getSimpleProductMetadata()

Get simple product metadata

array
getCustomProductFieldsForExport(array $fields)

Find custom product fields for export

getReference(int $id)

Find product reference

bool|Proxy|null|object
getReferenceForClass(string $className, int $id)

Find entity reference by class name and id

deleteQueryCache(string $key)

Remove cached keys

array
getAllProductsWithBrandNameAndCategoryConcatFromArray(array $productsArray)

Find products with brand and category for provided array of product ids

array
getEntitiesForBlockElementsExtension(array $ids, $limitData = null)

No description

array
getAllProductsOnAction(array|null $limitData = null)

Find all products on action

array
getProductReferencesForArrayIds(array $ids)

Find reference for array of products

getProductAttributeValues(int $productId)

Find product attribute value by product id

array
getAttrsForProducts(array $pavsArray, bool $includeBrands = true, null|array $attributesOrder = null, null|array $disabledAttrs = null, null|array $closures = null, ProductSearchWrapper|null $searchWrapper = null)

Find all product filters data

deleteProductsOnActionCache()

Delete cache for products on action page

array
getAllAvailableProductAndAttributeSet(array $prodArray)

Find all products and their attribute sets

array
getAllProductsErpCodes(array $aditionalFields = [])

Get product codes

array
getAllSimpleProductErpCodes()

Get all ids of product and simple product codes

array
getAllProductsIdAndNameDescription()

Find all products main information

array
getAllProductsWithoutPrice()

Get ids of products without price

array
getAllProductsWithoutSimpleProduct()

Get ids of products without simple product

bool|string
saveMultiple(array $products, int $flushNumber = 30)

Persist collection of products with custom id

array
getProductsByCategorySimple(int $id)

Find products by category id

array
getProductsByCategoryWithPaginationSimple(Category $category, int $page, int $offset, bool $count, array|null $searchParams = null)

Find products by category id with pagination or count them

array
getEntityNamesForIds(array $ids)

No description

array
getProductsForProductSearchUpdate(array $ids, bool $isProductSearch)

Find products for product search update

bool
updateStatusForNewProducts(int $numberOfDays)

Update product isNew property

array
findProductsMissingFromDbCSVImport(array $productArray)

Find id of products in database for provided array of ids

array
getIdNameErpCodeOfAllProducts(array $conditions = array(), bool $count = false, int|null $page = null, int $offset = 30)

Find id, productName, erpCode and sku of products with pagination or count them

array
getCurrentPrices()

Find all products prices

updateProductViewCount(Product $product)

Increment product viewCount filed

array
getErpCodesOfProductAndPav()

Find all erpCodes of products and product attribute values

bool
doCustomSqlQuery(string $sql)

Execute custom sql

bool|string
reCacheProductPricelistItemsArray()

Re-cache product price list items array field

bool|Exception
updateProductSalesCount(DateTime $date = null)

Increment product salesCount property

bool|Exception
updateCustomProductLinks(array $customProductLinks)

Update product customProductLinks property

array
findProductsByErpCode(array $codes)

Find products by array of erpCode

bool
editProductsFromArray(array $array, OutputInterface $output)

Edit collection of products

updatePreventDirectAddToCartField()

Prevent product add to cart

array
getPricesForProducts(ProductSearchWrapper $searchWrapper)

Find products prices

boolean|Exception
updateProductsWithCustomLabels(string $label, array $productIds)

Update products with custom labels

bool
updateMultipleProductsRatings(float $newRating, array $brandsArray)

Update product rating for provided array of brands

Details

in JQGridTrait at line 27
jQGridJoinFields(QueryBuilder $qb, JQGridWrapper $jqGridWrapper)

All joins used in select.

Override in the repository class if needed. Should do nothing otherwise

Parameters

QueryBuilder $qb
JQGridWrapper $jqGridWrapper

in JQGridTrait at line 42
jQGridGroupByFields(QueryBuilder $qb, JQGridWrapper $jqGridWrapper)

Should contain group by which jqgrid uses.

Override in the repository class if needed. Should do nothing otherwise

Parameters

QueryBuilder $qb
JQGridWrapper $jqGridWrapper

in JQGridTrait at line 61
array findAllForJQGRID(int $page, int $offset, array $sortParams, array $additionalParams, JQGridWrapper $jqGridWrapper)

JQGrid function

Parameters

int $page
int $offset
array $sortParams
array $additionalParams
JQGridWrapper $jqGridWrapper

Return Value

array

in JQGridTrait at line 94
array searchForJQGRID(array $searchParams, array $sortParams, bool $isCountSearch = false, array $additionalParams = array(), JQGridWrapper $jqGridWrapper = null)

JQGrid function

Parameters

array $searchParams
array $sortParams
bool $isCountSearch
array $additionalParams
JQGridWrapper $jqGridWrapper

Return Value

array

productLimitDataDQL(QueryBuilder $qb, array $limitData)

Parameters

QueryBuilder $qb
array $limitData

string productLimitDataSQL(string $productAlias, array $limitData, bool $addAnd = true)

Parameters

string $productAlias
array $limitData
bool $addAnd

Return Value

string

brandLimitDataDQL(QueryBuilder $qb, array $limitData, string $brandAlias = null)

Parameters

QueryBuilder $qb
array $limitData
string $brandAlias

array getCustomPriceData(ProductSearchWrapper $searchWrapper)

get sql algorithm to use use when calculating price, action price, field to select action price

Parameters

ProductSearchWrapper $searchWrapper

Return Value

array

array doProductSearch(ProductSearchWrapper $searchWrapper)

Parameters

ProductSearchWrapper $searchWrapper

Return Value

array

at line 265
flushProducts(array|null $products = null)

Flush entity manager

Parameters

array|null $products

Exceptions

ORMException
OptimisticLockException

at line 282
PrimaryKeyInterface|int|null save(PrimaryKeyInterface $entity)

Persist new product

Parameters

PrimaryKeyInterface $entity

Return Value

PrimaryKeyInterface|int|null

Exceptions

Exception

at line 312
PrimaryKeyInterface|int|null edit(PrimaryKeyInterface $entity)

Merge product

Parameters

PrimaryKeyInterface $entity

Return Value

PrimaryKeyInterface|int|null

at line 339
EntityManager|EntityManagerInterface getEM()

Return Value

EntityManager|EntityManagerInterface

at line 352
array findProductsOnAction(mixed $page, mixed $offset, array|null $limitData = null)

Find products on action with pagination

Parameters

mixed $page
mixed $offset
array|null $limitData

Return Value

array

at line 408
updateQty(Product $product)

Update product quantities on simple product for specific products

Parameters

Product $product

Exceptions

DBALException

at line 424
updateProductQtyAfterPAV(ProductAttributeValues $pav)

Update product quantities on simple product for specific product attribute values

Parameters

ProductAttributeValues $pav

Exceptions

DBALException

at line 448
Product getProductById(Product $product)

Find product by id

Parameters

Product $product

Return Value

Product

Exceptions

NoResultException
NonUniqueResultException

at line 466
Product getProductByPrimaryKey(Product $entity)

Find product by id or slug

Parameters

Product $entity

Return Value

Product

Exceptions

NoResultException
NonUniqueResultException

at line 487
Product getProductForEdit(Product $entity)

Find product by id or slug

Parameters

Product $entity

Return Value

Product

Exceptions

NoResultException
NonUniqueResultException

at line 507
array getGroupProductsFromDB(array $array)

Find collection of products

Parameters

array $array

Return Value

array

at line 539
ArrayCollection saveCSV(ArrayCollection $objectList, Category $dbCategory = null, AttributeSet $dbAttributeSet = null)

Persist new products from array with custom id generator

Parameters

ArrayCollection $objectList
Category $dbCategory
AttributeSet $dbAttributeSet

Return Value

ArrayCollection

Exceptions

Exception

at line 592
Product findByErpCode(string $code)

Find product by erp code

Parameters

string $code

Return Value

Product

at line 611
array findMultipleByErpCode(array $arrayCodes)

Find products for provided array of ids

Parameters

array $arrayCodes

Return Value

array

at line 624
array findAllProductErpCodeSearchString()

Find all product id, erpCode and productSearchString fields

Return Value

array

at line 640
array getAttrValsForFilter(array $products)

Find all ids of attribute value, brand and category for provided array of products

Parameters

array $products

Return Value

array

Exceptions

DBALException

at line 704
Product getDBProductForProductPage(int $productId, array|null $limitData = null)

Find product by id

Parameters

int $productId
array|null $limitData

Return Value

Product

Exceptions

NoResultException
NonUniqueResultException

at line 750
array getProductQuickInformation(int $productId)

Find product information by id

Parameters

int $productId

Return Value

array

Exceptions

NoResultException
NonUniqueResultException

at line 799
Product getDBProductBySlugForProductPage(string $productSlug, array|null $limitData = null)

Find product by slug

Parameters

string $productSlug
array|null $limitData

Return Value

Product

Exceptions

NoResultException
NonUniqueResultException

at line 836
array getAllProductsFromArray(array $productsArray)

Find all product for provided array of ids

Parameters

array $productsArray

Return Value

array

at line 852
bool|stdClass deleteMultiple(array $products)

Remove products from array

Parameters

array $products

Return Value

bool|stdClass

at line 882
mixed saveProductCollectionFromCMD(array $array, OutputInterface|null $output = null)

Persist collection of products

Parameters

array $array
OutputInterface|null $output

Return Value

mixed

Exceptions

Exception

at line 980
startTransaction()

Start db transaction

at line 988
commitTransaction()

Commit db transaction

at line 996
rollbackTransaction()

Rollback db transaction

at line 1010
bool saveProductsFromArray(array $arrayOfProducts, OutputInterface|null $output = null)

Persist collecion of products

Parameters

array $arrayOfProducts
OutputInterface|null $output

Return Value

bool

Exceptions

Exception

at line 1094
array getProductsSlugsNoLocale()

Find all products slugs

Return Value

array

at line 1111
mixed getProductMetadata()

Get product metadata

Return Value

mixed

See also

Product

at line 1122
mixed getSimpleProductMetadata()

Get simple product metadata

Return Value

mixed

See also

SimpleProduct

at line 1133
array getCustomProductFieldsForExport(array $fields)

Find custom product fields for export

Parameters

array $fields

Return Value

array

at line 1173
Product getReference(int $id)

Find product reference

Parameters

int $id

Return Value

Product

Exceptions

ORMException

at line 1187
bool|Proxy|null|object getReferenceForClass(string $className, int $id)

Find entity reference by class name and id

Parameters

string $className
int $id

Return Value

bool|Proxy|null|object

Exceptions

ORMException

at line 1196
deleteQueryCache(string $key)

Remove cached keys

Parameters

string $key

at line 1207
array getAllProductsWithBrandNameAndCategoryConcatFromArray(array $productsArray)

Find products with brand and category for provided array of product ids

Parameters

array $productsArray

Return Value

array

at line 1237
array getEntitiesForBlockElementsExtension(array $ids, $limitData = null)

Parameters

array $ids
$limitData

Return Value

array

at line 1295
array getAllProductsOnAction(array|null $limitData = null)

Find all products on action

Parameters

array|null $limitData

Return Value

array

at line 1312
array getProductReferencesForArrayIds(array $ids)

Find reference for array of products

Parameters

array $ids

Return Value

array

at line 1331
Product getProductAttributeValues(int $productId)

Find product attribute value by product id

Parameters

int $productId

Return Value

Product

Exceptions

NonUniqueResultException

at line 1355
array getAttrsForProducts(array $pavsArray, bool $includeBrands = true, null|array $attributesOrder = null, null|array $disabledAttrs = null, null|array $closures = null, ProductSearchWrapper|null $searchWrapper = null)

Find all product filters data

Parameters

array $pavsArray
bool $includeBrands
null|array $attributesOrder
null|array $disabledAttrs
null|array $closures
ProductSearchWrapper|null $searchWrapper

Return Value

array

Exceptions

DBALException

at line 1423
deleteProductsOnActionCache()

Delete cache for products on action page

at line 1437
array getAllAvailableProductAndAttributeSet(array $prodArray)

Find all products and their attribute sets

Parameters

array $prodArray

Return Value

array

See also

Product
AttributeSet

at line 1459
array getAllProductsErpCodes(array $aditionalFields = [])

Get product codes

Parameters

array $aditionalFields

Return Value

array

See also

Product

at line 1481
array getAllSimpleProductErpCodes()

Get all ids of product and simple product codes

Return Value

array

See also

Product
SimpleProduct

at line 1496
array getAllProductsIdAndNameDescription()

Find all products main information

Return Value

array

See also

Product

at line 1515
array getAllProductsWithoutPrice()

Get ids of products without price

Return Value

array

at line 1530
array getAllProductsWithoutSimpleProduct()

Get ids of products without simple product

Return Value

array

at line 1548
bool|string saveMultiple(array $products, int $flushNumber = 30)

Persist collection of products with custom id

Parameters

array $products
int $flushNumber

Return Value

bool|string

at line 1578
array getProductsByCategorySimple(int $id)

Find products by category id

Parameters

int $id

Return Value

array

at line 1610
array getProductsByCategoryWithPaginationSimple(Category $category, int $page, int $offset, bool $count, array|null $searchParams = null)

Find products by category id with pagination or count them

Parameters

Category $category
int $page
int $offset
bool $count
array|null $searchParams

Return Value

array

Exceptions

DBALException

at line 1665
array getEntityNamesForIds(array $ids)

Parameters

array $ids

Return Value

array

at line 1691
array getProductsForProductSearchUpdate(array $ids, bool $isProductSearch)

Find products for product search update

Parameters

array $ids
bool $isProductSearch

Return Value

array

at line 1733
bool updateStatusForNewProducts(int $numberOfDays)

Update product isNew property

Parameters

int $numberOfDays

Return Value

bool

Exceptions

DBALException

See also

Product

at line 1748
array findProductsMissingFromDbCSVImport(array $productArray)

Find id of products in database for provided array of ids

Parameters

array $productArray

Return Value

array

at line 1766
array getIdNameErpCodeOfAllProducts(array $conditions = array(), bool $count = false, int|null $page = null, int $offset = 30)

Find id, productName, erpCode and sku of products with pagination or count them

Parameters

array $conditions
bool $count
int|null $page
int $offset

Return Value

array

at line 1804
array getCurrentPrices()

Find all products prices

Return Value

array

Exceptions

DBALException

at line 1821
updateProductViewCount(Product $product)

Increment product viewCount filed

Parameters

Product $product

Exceptions

DBALException

at line 1836
array getErpCodesOfProductAndPav()

Find all erpCodes of products and product attribute values

Return Value

array

See also

Product
ProductAttributeValues

at line 1854
bool doCustomSqlQuery(string $sql)

Execute custom sql

Parameters

string $sql

Return Value

bool

Exceptions

DBALException

at line 1869
bool|string reCacheProductPricelistItemsArray()

Re-cache product price list items array field

Return Value

bool|string

See also

Product

at line 1906
bool|Exception updateProductSalesCount(DateTime $date = null)

Increment product salesCount property

Parameters

DateTime $date

Return Value

bool|Exception

Update product customProductLinks property

Parameters

array $customProductLinks

Return Value

bool|Exception

at line 1968
array findProductsByErpCode(array $codes)

Find products by array of erpCode

Parameters

array $codes

Return Value

array

Exceptions

DBALException

at line 1989
bool editProductsFromArray(array $array, OutputInterface $output)

Edit collection of products

Parameters

array $array
OutputInterface $output

Return Value

bool

Exceptions

Exception

at line 2036
updatePreventDirectAddToCartField()

Prevent product add to cart

Exceptions

DBALException

See also

Product

at line 2054
array getPricesForProducts(ProductSearchWrapper $searchWrapper)

Find products prices

Parameters

ProductSearchWrapper $searchWrapper

Return Value

array

Exceptions

DBALException

at line 2090
boolean|Exception updateProductsWithCustomLabels(string $label, array $productIds)

Update products with custom labels

Parameters

string $label
array $productIds

Return Value

boolean|Exception

at line 2121
bool updateMultipleProductsRatings(float $newRating, array $brandsArray)

Update product rating for provided array of brands

Parameters

float $newRating
array $brandsArray

Return Value

bool