BConnect POS - Reference PHP

ProductController extends AbstractController
in package

Management of sale products (catalog).

Covers full CRUD, variants, images (upload + compression), barcodes, export, movement history, archiving, search, purchase-order preparation and AI-assisted description generation. All operations are scoped to the point of sale of the authenticated user.

Attributes
#[IsGranted]
'IS_AUTHENTICATED_FULLY'
#[Route]
'/product'

Table of Contents

Methods

addProductStockInProductSale()  : Response
Method for adding a productStock in productSale
archiver()  : RedirectResponse
Method for archived a product
create()  : Response
Method for creating a new product
datatable()  : JsonResponse
Provides paginated/filtered product data in the DataTables server-side format.
delete()  : RedirectResponse
Method for deleting a single product
deleteProductStock()  : RedirectResponse
Method for deleting a product
desarchiver()  : RedirectResponse
Method for desarchived a product
exportDownload()  : StreamedResponse
Download route: generates and streams an Excel file with filtered products.
exportPage()  : Response
Export page: displays the export form with standard and advanced filters.
generateDescription()  : JsonResponse
Generates an AI-assisted (Gemini) product description from the information provided in the request.
getAllProduct()  : JsonResponse
Method for get a quantity by single product
historiesDatatable()  : JsonResponse
Provides the movement history of a product in the DataTables server-side format.
index()  : Response
Index route to display the list of products.
indexArchive()  : Response
Displaying a list of products archived
manageBarcode()  : Response
purchaseOrderProduct()  : Response
Method for creating a purchase order for single product
search()  : Response
Method for searching a product via the search bar
show()  : Response
Show retail a single product
update()  : Response
Method for updating a single product
binaryResponse()  : Response
Method for returning a response by content
generatePurchaseNumber()  : string
Method for generate purchase order number
getLastPurchaseOrderNumberForYear()  : int
Method for geting a last purchase order number for a year from the database

Methods

addProductStockInProductSale()

Method for adding a productStock in productSale

public addProductStockInProductSale(Product $product, Request $request, EntityManagerInterface $entityManager) : Response
Parameters
$product : Product
$request : Request
$entityManager : EntityManagerInterface
Attributes
#[IsGranted]
'IS_AUTHENTICATED'
#[Route]
'/add/product/stock/{id}'
$name: "product.add.product-stock"
Return values
Response

archiver()

Method for archived a product

public archiver(Product $product, EntityManagerInterface $doctrine) : RedirectResponse
Parameters
$product : Product
$doctrine : EntityManagerInterface
Attributes
#[IsGranted]
'IS_AUTHENTICATED'
#[Route]
'/archive/{id}'
$name: 'product.archive'
Return values
RedirectResponse

create()

Method for creating a new product

public create(EntityManagerInterface $entityManager, Request $request, UploaderService $uploaderService) : Response
Parameters
$entityManager : EntityManagerInterface
$request : Request
$uploaderService : UploaderService
Attributes
#[IsGranted]
'IS_AUTHENTICATED'
#[Route]
'/create'
$name: 'product.create'
Return values
Response

datatable()

Provides paginated/filtered product data in the DataTables server-side format.

public datatable(EntityManagerInterface $entityManager, Request $request, DataTableService $dataTableService) : JsonResponse
Parameters
$entityManager : EntityManagerInterface

Doctrine entity manager.

$request : Request

Request carrying the DataTables parameters.

$dataTableService : DataTableService

Service building the DataTables response.

Attributes
#[IsGranted]
'IS_AUTHENTICATED'
#[Route]
'/datatable'
$name: 'product.datatable'
$methods: ['GET']
Return values
JsonResponse

DataTables-compatible JSON response.

delete()

Method for deleting a single product

public delete(EntityManagerInterface $doctrine, Product $product) : RedirectResponse
Parameters
$doctrine : EntityManagerInterface
$product : Product
Attributes
#[IsGranted]
'IS_AUTHENTICATED'
#[Route]
'/delete/{id}'
$name: 'product.delete'
Return values
RedirectResponse

deleteProductStock()

Method for deleting a product

public deleteProductStock(SaleProductStock $saleProductStock, EntityManagerInterface $entityManager) : RedirectResponse
Parameters
$saleProductStock : SaleProductStock
$entityManager : EntityManagerInterface
Attributes
#[IsGranted]
'IS_AUTHENTICATED'
#[Route]
'/delete/product/stock/{id}'
$name: 'product.delete.product.stock'
Return values
RedirectResponse

desarchiver()

Method for desarchived a product

public desarchiver(Product $product, EntityManagerInterface $doctrine) : RedirectResponse
Parameters
$product : Product
$doctrine : EntityManagerInterface
Attributes
#[IsGranted]
'IS_AUTHENTICATED'
#[Route]
'/desarchive/{id}'
$name: 'product.desarchive'
Return values
RedirectResponse

exportDownload()

Download route: generates and streams an Excel file with filtered products.

public exportDownload(Request $request, ProductExportService $exportService) : StreamedResponse
Parameters
$request : Request
$exportService : ProductExportService
Attributes
#[IsGranted]
'IS_AUTHENTICATED'
#[Route]
'/export/download'
$name: 'product.export.download'
Return values
StreamedResponse

exportPage()

Export page: displays the export form with standard and advanced filters.

public exportPage() : Response
Attributes
#[IsGranted]
'IS_AUTHENTICATED'
#[Route]
'/export'
$name: 'product.export'
Return values
Response

generateDescription()

Generates an AI-assisted (Gemini) product description from the information provided in the request.

public generateDescription(Request $request, AiGeneratorService $aiGenerator) : JsonResponse
Parameters
$request : Request

JSON request containing the product context.

$aiGenerator : AiGeneratorService

Service calling the generation model.

Attributes
#[Route]
'/generate-description'
$name: 'generate_description'
$methods: ['POST']
Return values
JsonResponse

The generated description (or an error message).

getAllProduct()

Method for get a quantity by single product

public getAllProduct(Product $product) : JsonResponse
Parameters
$product : Product
Attributes
#[IsGranted]
'IS_AUTHENTICATED'
#[Route]
'/get-product/{id}'
$name: 'product.all'
$methods: 'GET'
Return values
JsonResponse

historiesDatatable()

Provides the movement history of a product in the DataTables server-side format.

public historiesDatatable(Product $product, EntityManagerInterface $entityManager, Request $request, DataTableService $dataTableService) : JsonResponse
Parameters
$product : Product

Product whose history is listed.

$entityManager : EntityManagerInterface

Doctrine entity manager.

$request : Request

Request carrying the DataTables parameters.

$dataTableService : DataTableService

Service building the DataTables response.

Attributes
#[Route]
'/{id}/histories/datatable'
$name: 'product.histories.datatable'
$methods: ['GET']
Return values
JsonResponse

DataTables-compatible JSON response.

index()

Index route to display the list of products.

public index(EntityManagerInterface $entityManager, Request $request) : Response
Parameters
$entityManager : EntityManagerInterface
$request : Request
Attributes
#[IsGranted]
'IS_AUTHENTICATED'
#[Route]
'/'
$name: 'product.index'
Return values
Response

indexArchive()

Displaying a list of products archived

public indexArchive(EntityManagerInterface $entityManager) : Response
Parameters
$entityManager : EntityManagerInterface
Attributes
#[IsGranted]
'IS_AUTHENTICATED'
#[Route]
'/index/archive'
$name: 'product.index.archive'
Return values
Response

manageBarcode()

public manageBarcode(Product $product, EntityManagerInterface $em) : Response
Parameters
$product : Product
$em : EntityManagerInterface
Tags
throws
UnknownTypeException
Attributes
#[Route]
"/product/{id}/barcode"
$name: 'product.barcode'
Return values
Response

purchaseOrderProduct()

Method for creating a purchase order for single product

public purchaseOrderProduct(Product $product, EntityManagerInterface $entityManager, Request $request, UploaderService $uploaderService, MailerService $mailer) : Response
Parameters
$product : Product
$entityManager : EntityManagerInterface
$request : Request
$uploaderService : UploaderService
$mailer : MailerService
Tags
throws
NonUniqueResultException
TransportExceptionInterface
Attributes
#[Route]
'/purchase-order/{id}'
$name: 'product.purchase.order'
Return values
Response

Method for searching a product via the search bar

public search(Request $request, SearchService $searchService) : Response
Parameters
$request : Request
$searchService : SearchService
Attributes
#[IsGranted]
'IS_AUTHENTICATED'
#[Route]
'/search'
$name: 'product.search'
$methods: 'POST'
Return values
Response

show()

Show retail a single product

public show(Product $product, EntityManagerInterface $entityManager, Request $request, UploaderService $uploaderService) : Response
Parameters
$product : Product
$entityManager : EntityManagerInterface
$request : Request
$uploaderService : UploaderService
Attributes
#[IsGranted]
'IS_AUTHENTICATED'
#[Route]
'/show/{id}'
$name: 'product.show'
Return values
Response

update()

Method for updating a single product

public update(Product $product, EntityManagerInterface $doctrine, Request $request, UploaderService $uploaderService) : Response
Parameters
$product : Product
$doctrine : EntityManagerInterface
$request : Request
$uploaderService : UploaderService
Attributes
#[IsGranted]
'IS_AUTHENTICATED'
#[Route]
'/update/{id}'
$name: 'product.update'
Return values
Response

binaryResponse()

Method for returning a response by content

private binaryResponse(string $content, string $filename) : Response
Parameters
$content : string
$filename : string
Return values
Response

generatePurchaseNumber()

Method for generate purchase order number

private generatePurchaseNumber(EntityManagerInterface $entityManager) : string
Parameters
$entityManager : EntityManagerInterface
Tags
throws
NonUniqueResultException
Return values
string

getLastPurchaseOrderNumberForYear()

Method for geting a last purchase order number for a year from the database

private getLastPurchaseOrderNumberForYear(int $year, EntityManagerInterface $entityManager) : int
Parameters
$year : int
$entityManager : EntityManagerInterface
Tags
throws
NonUniqueResultException
Return values
int
On this page

Search results