Hi,
ItemManager saves RAM and loads its item-objects only when these are really required. There are a lot of
multiple "init(), quickInit(), limitedInit(), initAll() ..." functions that you can use to instruct ItemManager to load the items in the memory (RAM). For example, you can tell ItemManager to load all items of a specific category, or load just one specific item, or even load all the items of all categories at once (this could be very memory- and time-intensive if you have thousands of items)
Here're a few examples to get you started.
The first thing you need for getting working with items, is the "Item Accessor" variable - call it what you want, I call it "$itemMapper":
In the above example you posted (it's just an older method call), it is this line:
There I have named it different "$itemClass", but it means the same thing like "$itemMapper".
So, now, you can use that $itemMapper/$itemClass to working with your items. If you already know a category's id for the items you want to show, you can do following, to init all the items of this category:
or even (in your above example):
There you tells ItemManager to initialize all the items of a category $category_id. The $category_id is the "id" of your existing category, it can be 1, 2, 3 etc ...
You have now all the item-objects in the memory and you can working with these:
or in your example:
you can loop through the items and output each values you like:
or you can even search for a specific item in the memory:
or search for multiple items that are created after $timestamp (Unix timestamp):
etc ...
I hope this has given you an idea of some of the methods.
If you have any further questions - just ask. Good luck!
ItemManager saves RAM and loads its item-objects only when these are really required. There are a lot of
multiple "init(), quickInit(), limitedInit(), initAll() ..." functions that you can use to instruct ItemManager to load the items in the memory (RAM). For example, you can tell ItemManager to load all items of a specific category, or load just one specific item, or even load all the items of all categories at once (this could be very memory- and time-intensive if you have thousands of items)
Here're a few examples to get you started.
The first thing you need for getting working with items, is the "Item Accessor" variable - call it what you want, I call it "$itemMapper":
Code:
$itemMapper = $manager->getItemMapper();
In the above example you posted (it's just an older method call), it is this line:
Code:
$itemClass = $manager->getItemClass();
There I have named it different "$itemClass", but it means the same thing like "$itemMapper".
So, now, you can use that $itemMapper/$itemClass to working with your items. If you already know a category's id for the items you want to show, you can do following, to init all the items of this category:
Code:
$itemMapper->init($category_id);
or even (in your above example):
Code:
$itemClass->init($category_id);
There you tells ItemManager to initialize all the items of a category $category_id. The $category_id is the "id" of your existing category, it can be 1, 2, 3 etc ...
You have now all the item-objects in the memory and you can working with these:
Code:
$items = $itemMapper->items;
or in your example:
Code:
$items = $itemClass->items;
you can loop through the items and output each values you like:
Code:
foreach($items as $item) {
echo $item->name . "<br>";
...
}
or you can even search for a specific item in the memory:
Code:
$my_item = $itemClass->getItem('name= Your item name');
or search for multiple items that are created after $timestamp (Unix timestamp):
Code:
$my_items = $itemClass->getItems('created >'.$tilemtamp);
etc ...
I hope this has given you an idea of some of the methods.
If you have any further questions - just ask. Good luck!