### Example: Set Site Parameter to 'C' Source: https://github.com/aimeos/aimeos-docs/blob/master/src/typo3/customize.md An example demonstrating how to set the site parameter name to 'C' in the TypoScript setup, useful when the site code also corresponds to a country code parameter. ```typoscript plugin.tx_aimeos.settings.typo3.param.name.site = C ``` -------------------------------- ### Configure Setup Tasks Directory in manifest.php Source: https://github.com/aimeos/aimeos-docs/blob/master/src/developer/extensions.md List directories containing setup tasks for database structure creation and updates. ```php 'i18n' => [ 'setup', ] ``` -------------------------------- ### Configure Setup Task Directories Source: https://github.com/aimeos/aimeos-docs/blob/master/src/infrastructure/schema-migrations.md Specify directories where setup tasks are located by modifying the 'setup' key in the manifest.php file. This allows the setup manager to find and execute tasks. ```php return [ // ... 'setup' => [ 'setup', ], ]; ``` -------------------------------- ### PHPUnit Test Class Setup Source: https://github.com/aimeos/aimeos-docs/blob/master/src/infrastructure/filesystem.md Example of setting up a PHPUnit test class for a custom filesystem adapter. Ensure the test class name ends with 'Test.php' for PHPUnit recognition. ```php object = new \Aimeos\Base\Filesystem\MyFilesystem(); } public function testCopy() { // test copy() method } // remaining methods implemented in MyFilesystem class } ``` -------------------------------- ### Configuration File Example Source: https://github.com/aimeos/aimeos-docs/blob/master/src/developer/extensions.md An example of how configuration files are specified within the manifest.php. These files are located in the 'config' directory of the extension. ```php 'config' => [ 'config', ], ``` -------------------------------- ### Start Local Development Server Source: https://github.com/aimeos/aimeos-docs/blob/master/README.md Run 'mkdocs serve' to start a local development server. It will automatically reload when changes are detected in the repository files. ```bash mkdocs serve ``` -------------------------------- ### Example Template File Names Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/html/overwrite-templates.md Examples illustrating the template file naming convention for components and their subparts. ```plaintext catalog/detail/header.php ``` ```plaintext catalog/detail/service-body-mine.php ``` -------------------------------- ### Example of setting catalog manager class Source: https://github.com/aimeos/aimeos-docs/blob/master/src/config/mshop/catalog-manager.md Example showing how to set the 'mshop/catalog/manager/name' configuration to use a custom catalog manager implementation. ```properties mshop/catalog/manager/name = Mymanager ``` -------------------------------- ### Install MkDocs and Dependencies Source: https://github.com/aimeos/aimeos-docs/blob/master/README.md Install mkdocs and the necessary dependencies for aimeos-docs using pip. This includes mkdocs-material and any plugins. ```bash pip install mkdocs mkdocs-material pip install plugins/ ``` -------------------------------- ### Setup Aimeos Site with Custom Domain Source: https://github.com/aimeos/aimeos-docs/blob/master/src/laravel/customize.md Use the `aimeos:setup` Artisan command to set the site code, which will be used as the domain for your shops. ```bash php artisan aimeos:setup shop.mydomain.com ``` ```bash php artisan aimeos:setup myshop.com ``` -------------------------------- ### Example of Custom Log Manager Class Name Source: https://github.com/aimeos/aimeos-docs/blob/master/src/config/madmin/log-manager.md Example demonstrating how to set the 'madmin/log/manager/name' configuration to use a custom log manager implementation. ```config madmin/log/manager/name = Mymanager ``` -------------------------------- ### Install Laravel Mix and Browser Sync Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/html/create-themes.md Install necessary development tools for hot reloading of theme assets in a Laravel project. ```bash npm install laravel-mix --save-dev npm install -g browser-sync ``` -------------------------------- ### Front-end Translation Example Source: https://github.com/aimeos/aimeos-docs/blob/master/src/providers/service/index.md Example of how to add translations for configuration labels in a Laravel `config/shop.php` file. ```php 'i18n' => [ 'en' => [ 'client/code' => [ 'myprovider.username' => ['User name'] ] ] ] ``` -------------------------------- ### JQAdm Example for Customer Search Source: https://github.com/aimeos/aimeos-docs/blob/master/src/admin/graphql/customer.md This example demonstrates how to perform a customer search query within the JQAdm environment using the Aimeos.query method. ```javascript Aimeos.query(`query { searchCustomers(filter: "{\"=~\": {\"customer.code\":\"demo-\"}}", ["product", "customer/property"]) { items { id siteid code label salutation company vatid title firstname lastname address1 address2 address3 postal city state languageid countryid telephone email telefax website longitude status latitude birthday status dateverified password mtime ctime editor lists { product { id { item { id label } } } } property { id type languageid value } } total } }`).then(data => { console.log(data) }) ``` -------------------------------- ### Example Custom Controller Class Source: https://github.com/aimeos/aimeos-docs/blob/master/src/config/controller-frontend/catalog.md Shows an example of a custom catalog frontend controller class name. ```php \Aimeos\Controller\Frontend\Catalog\Mycatalog ``` -------------------------------- ### Example Custom Controller Class Source: https://github.com/aimeos/aimeos-docs/blob/master/src/config/controller-frontend/customer.md An example of a custom customer frontend controller class name. ```php \Aimeos\Controller\Frontend\Customer\Mycustomer ``` -------------------------------- ### Example Default Controller Class Source: https://github.com/aimeos/aimeos-docs/blob/master/src/config/controller-frontend/customer.md An example of a default customer frontend controller class name. ```php \Aimeos\Controller\Frontend\Customer\Standard ``` -------------------------------- ### Install Payone Payment Gateway Source: https://github.com/aimeos/aimeos-docs/blob/master/src/manual/services.md Use this composer command to install the Payone payment gateway integration. Ensure you have the necessary dependencies installed. ```bash composer req aimeos/ai-payments academe/omnipay-payone ``` -------------------------------- ### Fetch Customer Data Example Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/jsonapi/customer.md This example shows a typical JSON:API response structure for customer data, including attributes and relationships. ```json { "data": { "id": "2", "type": "customer", "attributes": { "customer.id": "2", "customer.salutation": "mr", "customer.company": "Test company", "customer.vatid": "DE12345678", "customer.title": "Dr.", "customer.firstname": "Test", "customer.lastname": "User", "customer.address1": "Test street", "customer.address2": "1", "customer.address3": "2. floor", "customer.postal": "12345", "customer.city": "Test city", "customer.state": "HH", "customer.languageid": "de", "customer.countryid": "DE", "customer.telephone": "+49012345678", "customer.email": "example@aimeos.org", "customer.telefax": "+490123456789", "customer.website": "https://aimeos.org", "customer.longitude": 10.0, "customer.latitude": 50.0, "customer.label": "Test User", "customer.code": "example@aimeos.org", "customer.birthday": "2000-01-01" }, "relationships": { "group": { "data": [ { "id": "1", "type": "group", "attributes": { "customer.lists.id": "1", "customer.lists.domain": "customer/group", "customer.lists.refid": "1", "customer.lists.datestart": null, "customer.lists.dateend": null, "customer.lists.config": [], "customer.lists.position": 0, "customer.lists.status": 1, "customer.lists.type": "default" }, "links": { "self": { "href": "http://localhost:8000/jsonapi/customer/group?id=2&related=relationships&relatedid=1", "allow": [] } } } ] } } }, "included": [ { "id": "1", "type": "group", "attributes": { "group.id": "1", "group.code": "admin", "group.label": "Administrator" } } ] } ``` -------------------------------- ### Paginate Results (Offset and Limit) Source: https://github.com/aimeos/aimeos-docs/blob/master/src/admin/jsonadm/search-filter.md Combine 'offset' and 'limit' in the 'page' parameter to retrieve specific slices of the result set. This example gets 100 items starting from the 300th item. ```bash curl -b cookies.txt -c cookies.txt \ -X GET 'http://localhost:8000/jsonapi/product?sort=-product.status,product.id' ``` ```javascript var params = { page: { offset: 300, limit: 100 } }; $.ajax({ method: "GET", dataType: "json", url: options.meta.resources['product'], // returned from OPTIONS response data: params }).done( function( result ) { console.log( result.data ); }); ``` -------------------------------- ### Execute Job Controller Command Examples Source: https://github.com/aimeos/aimeos-docs/blob/master/src/cronjobs/create-job-controller.md Shows how to execute a job controller from the command line using different frameworks. ```bash php artisan aimeos:jobs product/export/sitemap # Laravel ``` ```bash php console/bin aimeos:jobs product/export/sitemap # Symfony ``` ```bash php vendor/bin/typo3 aimeos:jobs product/export/sitemap # TYPO3 ``` -------------------------------- ### Negating a Condition Source: https://github.com/aimeos/aimeos-docs/blob/master/src/admin/jsonadm/search-filter.md Example of how to filter out products whose labels start with 'demo' using the negation operator ('!'). ```APIDOC ## GET /jsonapi/product?filter[!][][=~][product.label]=demo ### Description Retrieves product items that do NOT meet a specific condition. This example filters for products whose labels do NOT start with 'demo'. ### Method GET ### Endpoint `/jsonapi/product` ### Query Parameters - **filter[!][][=~][product.label]** (string) - Required - Filters out products where 'product.label' starts with 'demo'. ### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Configure Setup Menu Access Groups Source: https://github.com/aimeos/aimeos-docs/blob/master/src/config/admin-jqadm/resource.md Lists the user groups authorized to access the setup menu. This setting is available since 2021.04. ```php admin/jqadm/resource/setup/groups = Array ( [0] => admin [1] => super ) ``` -------------------------------- ### Install Theme Extension via Composer Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/html/create-themes.md Use this composer command to install your theme package. Ensure your theme is distributed via a supported composer repository. ```bash composer req aimeos-themes/ ``` -------------------------------- ### Reduce Product Prices by 10% Source: https://github.com/aimeos/aimeos-docs/blob/master/src/providers/rules.md This example demonstrates how to iterate through a product's prices, calculate a 10% discount, and apply it by updating the price value and setting the rebate. Ensure the `apply` method remains fast as it's called frequently. ```php public function apply( \Aimeos\MShop\Product\Item\Iface $product ) : bool { foreach( $product->getRefItems( 'price' ) as $price ) { $value = $price->getValue(); $discount = $value * 10 / 100; $price->setValue( $value - $discount )->setRebate( $discount ); } return $this->isLast(); } ``` -------------------------------- ### Count Reviews by Rating Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/jsonapi/reviews.md Use the 'aggregate' parameter with 'review.rating' to get the count of reviews for each rating. This example uses CURL. ```bash curl -X GET 'http://localhost:8000/jsonapi/review?aggregate=review.rating' ``` -------------------------------- ### Filter Products by Type (CURL) Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/jsonapi/basics.md Use this CURL command to filter product items by their type, for example, to get all 'select' type products. ```bash # filter[>][product.type]=select curl -X GET 'http://localhost:8000/jsonapi/product?filter[%3E][product.type]=select' ``` -------------------------------- ### Get Attribute Counts via Javascript Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/jsonapi/catalog.md Implement attribute counting in Javascript using the fetch API. This example assumes 'options.meta' is populated from an OPTIONS call. ```javascript const args = { 'aggregate': 'index.attribute.id' } let params = {} if(options.meta.prefix) { // returned from OPTIONS call params[options.meta.prefix] = args } else { params = args } // returned from OPTIONS call const url = options.meta.resources['product'] + (options.meta.resources['product'].includes('?') ? '&' : '?') + window.param(params) // from https://github.com/knowledgecode/jquery-param fetch(url).then(result => { if(!result.ok) { throw new Error(`Response error: ${response.status}`) } return result.json() }).then(result => { console.log(result.data) }) ``` -------------------------------- ### Setup Database for Extension Tests Source: https://github.com/aimeos/aimeos-docs/blob/master/src/developer/extensions.md Use this Phing command to populate the database with unit test data. Ensure the Aimeos core is cloned and database configuration is set up. ```bash vendor/bin/phing setup ``` -------------------------------- ### Count Reviews by Rating in jQuery Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/jsonapi/reviews.md Use $.ajax to send a GET request with the 'aggregate' parameter set to 'review.rating'. This example includes handling for potential prefixes. ```javascript var args = {'aggregate': 'review.rating'}; var params = {}; if(options.meta.prefix) { // returned from OPTIONS call params[options.meta.prefix] = args; } else { params = args; } $.ajax({ method: 'GET', dataType: 'json', url: options.meta.resources['review'], // returned from OPTIONS call data: params }).done( function( result ) { console.log( result ); }); ``` -------------------------------- ### Configure Suggest Keys for Product Media Configuration Source: https://github.com/aimeos/aimeos-docs/blob/master/src/config/admin-jqadm/product.md Lists suggested configuration keys for the product media panel. Defaults to an empty array. ```php admin/jqadm/product/item/media/config/suggest = Array ( ) ``` -------------------------------- ### GraphQL Admin API: Get Product Response Example Source: https://context7.com/aimeos/aimeos-docs/llms.txt This is an example of the JSON response structure when retrieving a single product by ID using the GraphQL Admin API. It details the fields returned for the product, including its ID, code, label, status, associated texts, properties, and stock information. ```json // Expected response for getProduct: // { // "data": { // "getProduct": { // "id": "113", "siteid": "1.", "type": "default", // "code": "demo-article", "label": "Demo article", // "status": 1, "boost": 1, // "lists": { "text": [{ "id": "1", "item": { "id": "10", "content": "Test content" } }] }, // "property": [{ "id": "1", "type": "isbn", "languageid": null, "value": "12345678" }], // "stock": [{ "id": "23", "type": "default", "stocklevel": 42, "timeframe": "2-3d" }] // } // } // } ``` -------------------------------- ### Basic Setup Task Structure Source: https://github.com/aimeos/aimeos-docs/blob/master/src/infrastructure/schema-migrations.md Defines the basic structure of a setup task class, including optional before() and after() methods for managing task dependencies and the main up() method for schema and data migration. ```php namespace Aimeos\Upscheme\Task; class TaskClassName extends Base { /** * This task will run after the returned list of task names * * @return array List of task names */ public function after() : array { return []; } /** * This task will run before the returned list of task names * * @return array List of task names */ public function before() : array { return []; } /** * Updates the schema and migrates the data */ public function up() { $this->info( 'Migrating ...', 'v' ); // ... } } ``` -------------------------------- ### Helper Method to Get Order Item Source: https://github.com/aimeos/aimeos-docs/blob/master/src/providers/service/unittests.md Provides a reusable method to fetch a specific order item for use in tests when needed, avoiding database calls in the setup. ```php protected function getOrderItem() { $manager = \Aimeos\MShop::create( \TestHelper::context(), 'order' ); $filter = $manager->filter()->add( 'order.datepayment', '==', '2008-02-15 12:34:56' ); $return $manager->search( $filter )->first( new \Exception( 'No order found' ) ); } ``` -------------------------------- ### Create and Use a Manager Source: https://github.com/aimeos/aimeos-docs/blob/master/src/models/create-managers.md Demonstrates creating a manager for a sub-domain or a new domain, creating and saving an item, retrieving it, and accessing its properties. Also shows standard manager methods for searching and deleting items. ```php // sub-manager of existing domain $manager = \Aimeos\MShop::create( $this->context(), 'product/test' ); // new data domain $manager = \Aimeos\MShop::create( $this->context(), 'test' ) $item = $manager->create() ->set( 'label', 'test label' ) ->set( 'position', 2 ) ->set( 'status', 1 ); $item = $manager->save( $item ); $item = $manager->get( $item->getId() ); $label = $item->label; // or using get() with default value $label = $item->get( 'label', 'default value' ); // standard methods $id = $item->getId(); $siteid = $item->getSiteId(); $ctime = $item->getTimeCreated(); $mtime = $item->getTimeModified(); $editor = $item->getEditor(); $items = $manager->search( $manager->filter() ); $manager->delete( $items ); ``` -------------------------------- ### Example of Replacing Default Controller Source: https://github.com/aimeos/aimeos-docs/blob/master/src/config/controller-jobs/product-bought.md Illustrates how to configure a custom product bought controller by setting the 'name' parameter to the last part of the custom class name. ```config controller/jobs/product/bought/name = Myalgorithm ``` -------------------------------- ### Sort Reviews by Rating (Descending) in jQuery Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/jsonapi/reviews.md Use $.ajax to send a GET request with the 'sort' parameter for descending order. This example includes handling for potential prefixes. ```javascript var args = {'sort': '-rating'}; var params = {}; if(options.meta.prefix) { // returned from OPTIONS call params[options.meta.prefix] = params; } else { params = args; } $.ajax({ method: "GET", dataType: "json", url: options.meta.resources['review'], // returned from OPTIONS call data: params }).done( function( result ) { console.log( result ); }); ``` -------------------------------- ### Get Catalog Tree Source: https://github.com/aimeos/aimeos-docs/blob/master/src/admin/graphql/catalog.md This operation retrieves the category tree structure. You can specify the starting category ID, the maximum depth of the tree to retrieve, and which fields to include in the response. ```APIDOC ## Get Catalog Tree ### Description Retrieves the category tree structure starting from a specified ID, with options to limit the depth and include specific fields. ### Method POST ### Endpoint ### Parameters #### Query Parameters - **query** (String) - Required - The GraphQL query string. - **getCatalogTree** (Object) - The root field for retrieving the catalog tree. - **id** (String) - Required - The ID of the category to start from. - **level** (Int) - Optional - The maximum depth of the category tree to retrieve. - **include** (Array of Strings) - Optional - A list of fields to include in the response (e.g., "text"). ### Request Example ```json { "query": "query { getCatalogTree(id: \"1\", level: 3, include: [\"text\"]) { id label lists { text { id item { id content } } } children { id label lists { text { id item { id content } } } children { id label } } } }" } ``` ### Response #### Success Response (200) - **data** (Object) - The response data. - **getCatalogTree** (Object) - The retrieved category tree. - **id** (String) - The ID of the category. - **label** (String) - The display name of the category. - **lists** (Object) - Contains lists of items associated with the category. - **text** (Array of Objects) - List of text items. - **id** (String) - The ID of the text item. - **item** (Object) - Details of the item. - **id** (String) - The ID of the item. - **content** (String) - The content of the item. - **children** (Array of Objects) - An array of child categories. - **id** (String) - The ID of the child category. - **label** (String) - The display name of the child category. - **lists** (Object) - Contains lists of items associated with the child category. - **children** (Array of Objects) - An array of grandchild categories. ### Response Example ```json { "data": { "getCatalogTree": { "id": "1", "label": "Home", "lists": { "text": [ { "id": "1", "item": { "id": "10", "content": "Test content" } } ] }, "children": [ { "id": "2", "label": "Best sellers", "lists": { "text": [] }, "children": [ { "id": "3", "label": "Women" }, { "id": "7", "label": "Shirts" }, { "id": "12", "label": "Men" }, { "id": "15", "label": "Misc" } ] }, { "id": "16", "label": "New arrivals", "lists": { "text": [] }, "children": [] }, { "id": "17", "label": "Hot deals", "lists": { "text": [] }, "children": [] } ] } } } ``` ``` -------------------------------- ### Example Custom Client Class Name Source: https://github.com/aimeos/aimeos-docs/blob/master/src/config/client-html/catalog-home.md Demonstrates how to set the configuration value to the last part of a custom class name, e.g., 'Myhome' for '\Aimeos\Client\Html\Catalog\Home\Myhome'. ```text client/html/catalog/home/name = Myhome ``` -------------------------------- ### Component-Specific CSS Styling Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/html/theme-basics.md Example of how to target a specific element within a component's subpart for styling. Always start with the most specific selector to avoid unintended side effects. ```css .catalog-detail-basic .name { font-size: 125% } ``` -------------------------------- ### Fetch Products with Included Properties Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/jsonapi/basics.md This example demonstrates how to fetch product data and include its associated properties using the `include` query parameter. It shows examples for CURL, Javascript, and jQuery. ```APIDOC ## GET /jsonapi/product?include=product.property ### Description Fetches product resources and includes their related properties. ### Method GET ### Endpoint `/jsonapi/product` ### Parameters #### Query Parameters - **include** (string) - Required - Specifies related resources to include in the response, e.g., `product.property`. ``` ```APIDOC ## Javascript Example ### Description Example of fetching products with included properties using Javascript's Fetch API. ### Code ```javascript const args = { 'include': 'product.property' } let params = {} if(options.meta.prefix) { // returned from OPTIONS call params[options.meta.prefix] = args } else { params = args } // returned from OPTIONS call const url = options.meta.resources['product'] + (options.meta.resources['product'].includes('?') ? '&' : '?') + window.param(params) // from https://github.com/knowledgecode/jquery-param fetch(url).then(result => { if(!result.ok) { throw new Error(`Response error: ${response.status}`) } return result.json() }).then(result => { console.log(result.data) }) ``` ``` ```APIDOC ## jQuery Example ### Description Example of fetching products with included properties using jQuery's AJAX. ### Code ```javascript var args = { 'include': 'product.property' }; var params = {}; if(options.meta.prefix) { // returned from OPTIONS call params[options.meta.prefix] = args; } else { params = args } $.ajax({ method: "GET", dataType: "json", url: options.meta.resources['product'], // returned from OPTIONS call data: params }).done( function( result ) { console.log( result.data ); }); ``` ``` ```APIDOC ## CURL Example ### Description Example of fetching products with included properties using CURL. ### Code ```bash curl -X GET 'http://localhost:8000/jsonapi/product?include=product.property' ``` ``` ```APIDOC ## Response Example ### Description Example of a successful response when fetching products with included properties. ### Success Response (200) ```json { "data": [{ "id": "1", "type": "product", "attributes": { "product.id": "1", "product.type": "default", "product.code": "demo-article", "product.label": "Demo article", "product.status": 1, "product.dataset": "", "product.datestart": null, "product.dateend": null, "product.config": [], "product.target": "", "product.ctime": "2020-07-28 08:41:18" }, "relationships": { "product.property": { "data": [ { "id": "1", "type": "product.property" },{ "id": "2", "type": "product.property" },{ "id": "3", "type": "product.property" },{ "id": "4", "type": "product.property" } ] } } }], "included": [ { "id": "1", "type": "product.property", "attributes": { "product.property.id": "1", "product.property.languageid": null, "product.property.value": "20.00", "product.property.type": "package-length" } },{ "id": "2", "type": "product.property", "attributes": { "product.property.id": "2", "product.property.languageid": null, "product.property.value": "10.00", "product.property.type": "package-width" } },{ "id": "3", "type": "product.property", "attributes": { "product.property.id": "3", "product.property.languageid": null, "product.property.value": "5.00", "product.property.type": "package-height" } },{ "id": "4", "type": "product.property", "attributes": { "product.property.id": "4", "product.property.languageid": null, "product.property.value": "2.5", "product.property.type": "package-weight" } } ] } ``` ``` -------------------------------- ### Including Subpart Templates Source: https://github.com/aimeos/aimeos-docs/blob/master/src/infrastructure/view.md Includes subpart templates within component templates. Use `block()->get()` to retrieve content and `block()->start()`/`block()->stop()` to define content for a block. ```html Test template block()->get( 'content' ) ?> ``` ```html block()->start( 'content' ) ?>

Test

block()->stop(); ?> ``` -------------------------------- ### Get Supplier Product Counts via jQuery Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/jsonapi/catalog.md This jQuery AJAX example shows how to retrieve aggregated product counts per supplier. It includes logic for handling API resource prefixes. ```javascript var args = {'aggregate': 'index.supplier.id'}; var params = {}; if(options.meta.prefix) { // returned from OPTIONS call params[options.meta.prefix] = args; } else { params = args; } $.ajax({ method: 'GET', dataType: 'json', url: options.meta.resources['product'], // returned from OPTIONS call data: params }).done( function( result ) { console.log( result ); }); ``` -------------------------------- ### Configuration with Value Lists Source: https://github.com/aimeos/aimeos-docs/blob/master/src/laravel/customize.md Shows how to configure array values for specific settings. ```php 'client' => [ 'html' => [ 'catalog' => [ 'filter' => [ 'subparts' => ['search', 'tree', 'attribute'], ], ], ], ], ``` -------------------------------- ### Get Products by Category ID (jQuery) Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/jsonapi/catalog.md Use the `f_catid` filter to retrieve products belonging to a specific category. This example demonstrates fetching products using jQuery's AJAX method. ```javascript var args = { 'filter': { 'f_catid': '1' } }; var params = {}; if(options.meta.prefix) { // returned from OPTIONS call params[options.meta.prefix] = args; } else { params = args; } $.ajax({ method: 'GET', dataType: 'json', url: options.meta.resources['product'], // returned from OPTIONS call data: params }).done( function( result ) { console.log( result ); }); ``` -------------------------------- ### Get Products by Category ID (Javascript) Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/jsonapi/catalog.md Use the `f_catid` filter to retrieve products belonging to a specific category. This example demonstrates fetching products using Javascript's Fetch API. ```javascript const args = { 'filter': { 'f_catid': '1' } } let params = {} if(options.meta.prefix) { // returned from OPTIONS call params[options.meta.prefix] = args } else { params = args } // returned from OPTIONS call const url = options.meta.resources['product'] + (options.meta.resources['product'].includes('?') ? '&' : '?') + window.param(params) // from https://github.com/knowledgecode/jquery-param fetch(url).then(result => { if(!result.ok) { throw new Error(`Response error: ${response.status}`) } return result.json() }).then(result => { console.log(result.data) }) ``` -------------------------------- ### Configure Suggest Keys for Product Price Configuration Source: https://github.com/aimeos/aimeos-docs/blob/master/src/config/admin-jqadm/product.md Lists suggested configuration keys for the product price panel. Defaults to an empty array. ```php admin/jqadm/product/item/price/config/suggest = Array ( ) ``` -------------------------------- ### Filter Services by Type using jQuery Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/jsonapi/services.md Filter services by type using jQuery's AJAX method. This example sets up a GET request to fetch only delivery options and logs the result. ```javascript var args = { 'filter': { 'cs_type': 'delivery' } }; var params = {}; if(options.meta.prefix) { // returned from OPTIONS call params[options.meta.prefix] = args; } else { params = args; } $.ajax({ method: 'GET', dataType: 'json', url: options.meta.resources['service'], // returned from OPTIONS call data: params }).done( function( result ) { console.log( result ); }); ``` -------------------------------- ### Fetch Specific Resource Items (CURL) Source: https://github.com/aimeos/aimeos-docs/blob/master/src/admin/jsonadm/metadata.md After obtaining the resource URLs via OPTIONS, use the GET method with the specific resource URL to retrieve items. For example, this fetches product data. ```bash curl -b cookies.txt -c cookies.txt \ -X GET 'http://localhost:8000/admin/default/jsonadm/product' ``` -------------------------------- ### Filter Products by Price Less Than a Value (jQuery) Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/jsonapi/catalog.md This jQuery example shows how to send a GET request to filter products by price. It constructs the filter parameters and handles the AJAX call, logging the result. ```javascript var args = { 'filter': { '<': {'index.price:value("EUR")': 99.50} } }; var params = {}; if(options.meta.prefix) { // returned from OPTIONS call params[options.meta.prefix] = args; } else { params = args; } $.ajax({ method: 'GET', dataType: 'json', url: options.meta.resources['product'], // returned from OPTIONS call data: params }).done( function( result ) { console.log( result ); }); ``` -------------------------------- ### Configure Suggest Keys for Product Text Configuration Source: https://github.com/aimeos/aimeos-docs/blob/master/src/config/admin-jqadm/product.md Lists suggested configuration keys for the product text panel. Defaults to an empty array. ```php admin/jqadm/product/item/text/config/suggest = Array ( ) ``` -------------------------------- ### Paginate search results Source: https://github.com/aimeos/aimeos-docs/blob/master/src/models/search-filter.md Use the `slice()` method to control the number of items returned and the starting point. The first argument is the offset, and the second is the limit. This example retrieves items from position 100 to 150. ```php $filter->slice( 100, 50 ) ``` -------------------------------- ### Example Template File Names Source: https://github.com/aimeos/aimeos-docs/blob/master/src/admin/jqadm/overwrite-templates.md Illustrates common template file names based on the defined naming schema for different admin panels and subparts. ```text product/list.php product/item.php product/item-text.php product/item-characteristics-property.php ``` -------------------------------- ### CSV Column Mapping Example Source: https://github.com/aimeos/aimeos-docs/blob/master/src/cronjobs/stock-csv-import.md This example shows a CSV file with a header row and product data. It includes columns for product code, stock level, stock type, back date, and delivery timeframe. Ensure that any specified stock types are pre-configured in the admin backend. ```text "product code","stocklevel","stock type","back date","delivery timeframe" "demo-article",100,"","","2-3 days" "demo-article",0,"berlin","2100-01-01 00:00:00","4-5 days" ``` -------------------------------- ### Use a Custom Search Function in a Filter Source: https://github.com/aimeos/aimeos-docs/blob/master/src/models/extend-managers.md Apply a custom search function defined in your manager to a filter. This example uses the 'product:check' function to filter products based on valid start and end dates. ```php $filter->add( $filter->make( 'product:check', [] ), '==', true ) ``` -------------------------------- ### Fetch Customer Relationships via jQuery Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/jsonapi/customer-relations.md This jQuery AJAX example shows how to retrieve customer relationships. It constructs parameters and sends a GET request. Remember to include the 'include' parameter to fetch specific related data. ```javascript var url = response['links']['customer/relationships']['href']; // from customer response var args = {include: "product"}; var params = {}; if(options.meta.prefix) { // returned from OPTIONS call params[options.meta.prefix] = args; } else { params = args } $.ajax({ url: url, method: "GET", dataType: "json", data: params }).done( function( result ) { console.log( result.data ); }); ``` -------------------------------- ### Define a Search Function for Product Manager Source: https://github.com/aimeos/aimeos-docs/blob/master/src/models/extend-managers.md Add a 'search function' to your custom manager to support storage-specific code, like comparing two columns. This example defines a 'product:check' function for comparing start and end dates. ```php 'product:check' => [ 'code' => 'product:check()', 'internalcode' => '(mpro."start" < mpro."end)"', 'label' => 'Checks valid start/end dates', 'type' => 'boolean', 'internaltype' => 'boolean', 'public' => false, ], ``` -------------------------------- ### Build Local Documentation Source: https://github.com/aimeos/aimeos-docs/blob/master/README.md Use 'mkdocs build' to generate the static HTML files for the aimeos-docs locally. The output will be in the 'docs' folder of your clone. ```bash mkdocs build ``` -------------------------------- ### Test Direct Status Update Source: https://github.com/aimeos/aimeos-docs/blob/master/src/providers/service/unittests.md Test direct status updates by retrieving and saving modified orders. Use a stubbed save() method to prevent database changes. This example verifies GET parameter retrieval and checks if saveOrder() is called. ```php public function testUpdateSync() { $psr7request = $this->getMockBuilder( '\Psr\Http\Message\ServerRequestInterface' )->getMock(); $psr7request->expects( $this->once() )->method( 'getQueryParams' ) ->will( $this->returnValue( ['key' => 'value'] ) ); $this->object->expects( $this->once() )->method( 'saveOrder' ); $result = $this->object->updateSync( $psr7request, $this->getOrderItem() ); $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Iface', $result ); $this->assertEquals( \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED ); } ``` -------------------------------- ### Retrieve JSON API Service Description (Javascript) Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/jsonapi/index.md Fetch the service description from the Aimeos JSON API using JavaScript's fetch API. This example demonstrates how to get the base URL, parse the options, and then retrieve product data. ```javascript let url = 'http://localhost:8000/jsonapi'; // Base URL from config fetch(url, { method: "OPTIONS" }).then(result => { if(!result.ok) { throw new Error(`Response error: ${response.status}`) } return result.json() }).then(options => { const args = {}; let params = {}; if(options.meta.prefix) { // returned from OPTIONS call params[options.meta.prefix] = args; } else { params = args; } fetch(options.meta.resources['product']).then(result => { if(!result.ok) { throw new Error(`Response error: ${response.status}`) } return result.json() }).then(result => { console.log(result.data) }) }) ``` -------------------------------- ### PHPUnit: Skeleton for Job Controller Unit Tests Source: https://github.com/aimeos/aimeos-docs/blob/master/src/cronjobs/create-job-controller.md A basic structure for testing job controllers using PHPUnit. It includes setup and teardown methods for context and Aimeos object initialization and cleanup, along with example test methods for getName and getDescription. ```php namespace Aimeos\Controller\Jobs\Product\Export; class StandardTest extends \PHPUnit\Framework\TestCase { private $object; private $context; private $aimeos; protected function setUp() : void { \Aimeos\MShop::cache( true ); $this->context = \TestHelperJobs::context(); $this->aimeos = \TestHelperJobs::getAimeos(); $this->object = new \Aimeos\Controller\Jobs\Product\Export\Standard( $this->context, $this->aimeos ); } protected function tearDown() : void { \Aimeos\MShop::cache( false ); unset( $this->object, $this->context, $this->aimeos ); } public function testGetName() { $this->assertEquals( 'Product export', $this->object->getName() ); } public function testGetDescription() { $text = 'Exports all available products'; $this->assertEquals( $text, $this->object->getDescription() ); } public function testRun() { $this->object->run(); // test changes } } ``` -------------------------------- ### Create a Catalog Rule Provider Class Source: https://github.com/aimeos/aimeos-docs/blob/master/src/providers/rules.md Implement the `Aimeos\MShop\Rule\Provider\Base` class and the `Iface` and `Factory\Iface` interfaces to create a custom catalog rule provider. The `apply` method determines if the rule should be applied. ```php namespace Aimeos\MShop\Rule\Provider\Catalog; class Myprovider extends \Aimeos\MShop\Rule\Provider\Base implements \Aimeos\MShop\Rule\Provider\Catalog\Iface, \Aimeos\MShop\Rule\Provider\Factory\Iface { public function apply( \Aimeos\MShop\Product\Item\Iface $product ) : bool { return $this->isLast(); } } ``` -------------------------------- ### Get Attribute by ID (JavaScript Fetch API) Source: https://github.com/aimeos/aimeos-docs/blob/master/src/admin/graphql/attribute.md Make a POST request using the Fetch API to retrieve attribute data from a GraphQL endpoint. This example includes headers for Laravel CSRF protection. Replace placeholders for GraphQL URL and CSRF token. ```javascript const body = JSON.stringify({'query': `query { getAttribute(id: "1", include: ["text", "attribute/property"]) { id type siteid domain code label position status mtime ctime editor lists { text { id item { id content } } } property { id type languageid value } } }`}); fetch('', { method: 'POST', credentials: 'same-origin', headers: { // Laravel only 'X-CSRF-TOKEN': '' }, body: body }).then(response => { return response.json(); }).then(data => { console.log(data); }); ``` -------------------------------- ### Example of Setting Order Address Manager Class Name Source: https://github.com/aimeos/aimeos-docs/blob/master/src/config/mshop/order-manager.md Example demonstrating how to set the configuration value for the order address manager class name to a custom implementation. ```properties mshop/order/manager/address/name = Myaddress ``` -------------------------------- ### Get Review by ID (JavaScript Fetch) Source: https://github.com/aimeos/aimeos-docs/blob/master/src/admin/graphql/review.md Example of fetching a specific review by ID using JavaScript's fetch API. This includes setting up the POST request with the GraphQL query and handling the JSON response. Note the inclusion of CSRF token for Laravel environments. ```javascript const body = JSON.stringify({'query': `query { getReview(id: "1") { id siteid customerid orderproductid domain refid name comment response rating status mtime ctime editor } }`}); fetch('', { method: 'POST', credentials: 'same-origin', headers: { // Laravel only 'X-CSRF-TOKEN': '' }, body: body }).then(response => { return response.json(); }).then(data => { console.log(data); }); ``` -------------------------------- ### Retrieve products using Aimeos.query (JQAdm) Source: https://github.com/aimeos/aimeos-docs/blob/master/src/admin/graphql/basics.md This example demonstrates how to perform a searchProducts query using the Aimeos.query helper function within a JQAdm environment. It logs the retrieved data to the console. ```javascript Aimeos.query(`query { searchProducts(filter: "{}") { items { id type code label } total } }`).then(data => { console.log(data) }) ``` -------------------------------- ### Install PayPalPlus Payment Gateway Source: https://github.com/aimeos/aimeos-docs/blob/master/src/manual/services.md Use this composer command to install the PayPalPlus payment gateway integration. Ensure you have the necessary dependencies installed. ```bash composer req aimeos/ai-payments omnipay/paypal ``` -------------------------------- ### PHPUnit Test Class Setup Source: https://github.com/aimeos/aimeos-docs/blob/master/src/providers/service/unittests.md Sets up a test class for a service provider, including mocking dependencies and creating a service item. This method is executed before each test. ```php namespace Aimeos\MShop\Service\Provider\Payment; class MyproviderTest extends \PHPUnit_Framework_TestCase { private $object; private $serviceItem; protected function setUp() : void { $context = TestHelperMShop::context(); $serviceManager = Aimeos\MShop\Factory::createManager( $context, 'service' ); $this->serviceItem = $serviceManager->create(); $this->object = $this->getMockBuilder( 'Aimeos\MShop\Service\Provider\Payment\Myprovider' ) ->setConstructorArgs( [$context, $this->serviceItem] ) ->setMethods( ['save', 'myConnection'] ) ->getMock(); } } ``` -------------------------------- ### Configure Catalog Home Client Implementation Source: https://github.com/aimeos/aimeos-docs/blob/master/src/config/client-html/catalog-home.md Set the class name for the catalog home client implementation. This allows replacing the default implementation with a custom one. ```text client/html/catalog/home/name = ``` -------------------------------- ### Fetch Product Data for Basket Source: https://github.com/aimeos/aimeos-docs/blob/master/src/frontend/jsonapi/basket-products.md Example JSON response showing product data, including the link to add the product to the basket. Note that these URLs are dynamic and depend on your application's configuration. ```json { "data": [{ "id": "1", "type": "product", "links": { "self": { "href": "http://localhost:8000/jsonapi/product?id=1", "allow": ["GET"] }, "basket.product": { "href": "http://localhost:8000/jsonapi/basket?id=default&related=product", "allow": ["POST"] } }, }] } ``` -------------------------------- ### Include Related Resources (Text and Price) Source: https://github.com/aimeos/aimeos-docs/blob/master/src/admin/jsonadm/search-filter.md Use the 'include' parameter to fetch associated 'text' and 'price' resources along with the main product data. This minimizes the number of API requests needed. ```bash curl -b cookies.txt -c cookies.txt \ -X GET 'http://localhost:8000/jsonapi/product?include=text,price' ``` -------------------------------- ### Job Controller Directory Structure Example Source: https://github.com/aimeos/aimeos-docs/blob/master/src/cronjobs/create-job-controller.md Illustrates the typical directory structure for job controllers within an Aimeos extension. ```bash ./src/Controller/Jobs/Admin/ ./src/Controller/Jobs/Product/ ./src/Controller/Jobs/Order/ ``` ```bash ./src/Controller/Jobs/Product/Export/Sitemap/ -> product/export/sitemap ``` -------------------------------- ### Install Datatrans Package Source: https://github.com/aimeos/aimeos-docs/blob/master/src/manual/services.md Use this command to install the necessary packages for the Datatrans payment service provider. ```bash composer req aimeos/ai-payments academe/omnipay-datatrans ``` -------------------------------- ### Basic Configuration Change Source: https://github.com/aimeos/aimeos-docs/blob/master/src/laravel/customize.md Demonstrates how to map a configuration key with slashes to a nested array structure in PHP. ```text client/html/catalog/filter/button = 1 ``` ```php 'client' => [ 'html' => [ 'catalog' => [ 'filter' => [ 'button' => 1, ], ], ], ], ``` -------------------------------- ### Install ai-payments Extension Source: https://github.com/aimeos/aimeos-docs/blob/master/src/manual/services.md Use Composer to install the ai-payments extension for additional payment gateway support. ```bash composer req aimeos/ai-payments ``` -------------------------------- ### Configure Suggest Keys for Product Item Configuration Source: https://github.com/aimeos/aimeos-docs/blob/master/src/config/admin-jqadm/product.md Lists suggested configuration keys for the product item panel. Defaults to 'css-class'. ```php admin/jqadm/product/item/config/suggest = Array ( [0] => css-class ) ``` -------------------------------- ### Create an item with initial properties Source: https://github.com/aimeos/aimeos-docs/blob/master/src/models/managing-items.md Provide an array of key/value pairs to the create() method to initialize the item with specific properties. The item's state is not modified by this argument. ```php $item = $manager->create( [/*...*/] ); ``` ```php $item => $manager->create( ['domain.key1' => 'value1', 'domain.key2' => 'value2'] ) ``` ```php $item => $manager->create( ['product.code' => 'test', 'product.label' => 'Test'] ) ```