How to get the value of entitties.
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 8
- Joined: 05 Jul 2018, 05:02
How to get the value of entitties.
Sorry if this question sounds stupid but i need some help.
So, this is my controller code:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ProductsController extends Controller
{
public function index()
{
$context = app( '\Aimeos\Shop\Base\Context' )->get();
$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
$search = $manager->createSearch(true);
$expr = array(
$search->compare( '=~', 'product.code', 'demo-' ),
$search->getConditions(),
);
$search->setConditions( $search->combine( '&&', $expr ));
$search->setSortations( array( $search->sort( '+', 'product.id' )));
$search->setSlice( 0, 5 );
$total = 0;
$result = $manager->searchItems( $search, array( 'text' ), $total );
print_r($result);
$x=array();
foreach($result as $id => $item ) {
//???????How do i access Product label. I know I will get an object result with all the data. I can access the product id by $id. But how to access the product label,code,price etc.
}
}
}
I know this is a stupid question. Please help me...
So, this is my controller code:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ProductsController extends Controller
{
public function index()
{
$context = app( '\Aimeos\Shop\Base\Context' )->get();
$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
$search = $manager->createSearch(true);
$expr = array(
$search->compare( '=~', 'product.code', 'demo-' ),
$search->getConditions(),
);
$search->setConditions( $search->combine( '&&', $expr ));
$search->setSortations( array( $search->sort( '+', 'product.id' )));
$search->setSlice( 0, 5 );
$total = 0;
$result = $manager->searchItems( $search, array( 'text' ), $total );
print_r($result);
$x=array();
foreach($result as $id => $item ) {
//???????How do i access Product label. I know I will get an object result with all the data. I can access the product id by $id. But how to access the product label,code,price etc.
}
}
}
I know this is a stupid question. Please help me...
-
- Posts: 8
- Joined: 05 Jul 2018, 05:02
Re: How to get the value of entitties.
Also how to get the value of price. i dont see any price in the return object?
Do we have to add something while creating the manager?
Do we have to add something while creating the manager?
Re: How to get the value of entitties.
Please have a look at the API: https://aimeos.org/api/latest/class-Aim ... Iface.html
The product item has a method getLabel() and getName() as well as getRefItems(). Using the later one, you can get the prices, media, attributes, etc. if you add the required domain to the second parameter of searchItems():
The product item has a method getLabel() and getName() as well as getRefItems(). Using the later one, you can get the prices, media, attributes, etc. if you add the required domain to the second parameter of searchItems():
Code: Select all
$items = $manager->searchItems( $criteria, ['price', 'media', 'attribute' /* , ... */ );
foreach( $items as $item ) {
$item->getRefItems( 'price' /* ... */ );
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 8
- Joined: 05 Jul 2018, 05:02
Re: How to get the value of entitties.
ok so i am able to fetch everything. Just 1 more problem.
How to get the currency symbol displayed????
For USD- $
is there a function for that.??
How to get the currency symbol displayed????
For USD- $
is there a function for that.??
Re: How to get the value of entitties.
Use this code:
Code: Select all
$this->getContext()->getI18n()->dt( 'currency', 'EUR' );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star