Yii2, elasticsearch. How to assign my _id as primaryKey - elasticsearch

i'm newbie so I hope you can help me.
I have yii2 and i need to implement elasticSearch(ES).
All set up.
I made standart model and standart CRUD. Just a few changes to implement ES like
use yii\elasticsearch\ActiveRecord;
But I have a problem with getting _id in my view/index.php
to get _id in view.php i made
$model->_id = $model->primaryKey;
But how I can fix it with DataProvider in index.php?
my attributes
public function attributes()
{
return [
'_id',
'first_name',
'last_name',
'email',
'created',
'brand',
'product',
'qty',
'sum'
];
}
My rules
public function rules()
{
return [
[['first_name', 'last_name', 'email', 'created',
'brand', 'product', 'qty', 'sum'
],
'safe'],
[['qty'], 'integer'],
[['sum'], 'double'],
['email', 'email'],
];
}
I think it should work like with MongoDB, but it doesn't.
if I want to delete or view or update the data being on index.php I can se only such links w/o id
http://yii2.dev/index.php?r=elastic%2Fdelete&id=
Pls help
P.S.
Here is a var_dump
array (size=5)
0 =>
object(frontend\models\Elastic)[67]
private '_id' (yii\elasticsearch\ActiveRecord) => string 'AVreA6SUvBgWLKxTzUZn' (length=20)
private '_score' (yii\elasticsearch\ActiveRecord) => float 1
private '_version' (yii\elasticsearch\ActiveRecord) => null
private '_highlight' (yii\elasticsearch\ActiveRecord) => null
private '_attributes' (yii\db\BaseActiveRecord) =>
array (size=8)
'created' => string '2017-03-12' (length=10)
'first_name' => string 'Luka' (length=4)
'last_name' => string 'Signori' (length=7)
'email' => string 'l.signori#gmail.com' (length=19)
'brand' => string 'Apple' (length=5)
'product' => string 'iPad' (length=4)
'qty' => string '35' (length=2)
'sum' => string '600.00' (length=6)
private '_oldAttributes' (yii\db\BaseActiveRecord) =>
array (size=8)
'created' => string '2017-03-12' (length=10)
'first_name' => string 'Luka' (length=4)
'last_name' => string 'Signori' (length=7)
'email' => string 'l.signori#gmail.com' (length=19)
'brand' => string 'Apple' (length=5)
'product' => string 'iPad' (length=4)
'qty' => string '35' (length=2)
'sum' => string '600.00' (length=6)
private '_related' (yii\db\BaseActiveRecord) =>
array (size=0)
empty
private '_errors' (yii\base\Model) => null
private '_validators' (yii\base\Model) => null
private '_scenario' (yii\base\Model) => string 'default' (length=7)
private '_events' (yii\base\Component) =>
array (size=0)
empty
private '_behaviors' (yii\base\Component) =>
array (size=0)
empty

you can set.good luck
$dataProvider = new ActiveDataProvider([
'query' => $query,
'key' => ['your primaryKey']
'sort' => [
'defaultOrder' => ['datetime'=>SORT_DESC]
],
]);

Related

silex validator using last constraint from previous collection item

based on the tutorial for validation in silex i've created a constraint:
$constraint = new Assert\Collection([
'token' => [
new Assert\NotBlank(),
new Assert\Length(['min' => Constant::TOKEN_LENGTH, 'max' => Constant::TOKEN_LENGTH]),
],
'languageCode' => [
new Assert\NotBlank(),
new Assert\Choice(['choices' => [Constant::LANGUAGE_CODE_DE, Constant::LANGUAGE_CODE_EN]])
],
'startDate' => [
new Assert\NotBlank(),
new Assert\Date()
],
'endDate' => [
new Assert\NotBlank(),
new Assert\Date()
],
'duration' => [
new Assert\GreaterThanOrEqual(['value' => 1])
],
]);
which should match the following structures (here from json):
{
"token": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"languageCode": "DE",
"startDate": "2016-01-01",
"endDate": "2016-01-05",
"duration": 1
}
and
{
"token": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"languageCode": "DE",
"startDate": "2016-01-01",
"endDate": "2016-01-05"
}
While first example is validated as expected, the second (with the optional duration) will respond in a strange behavior: the constraints from "endDate" where used:
object(Symfony\Component\Validator\ConstraintViolationList)[154]
private 'violations' =>
array (size=1)
0 =>
object(Symfony\Component\Validator\ConstraintViolation)[158]
private 'message' => string 'This field is missing.' (length=22)
private 'messageTemplate' => string 'This field is missing.' (length=22)
private 'parameters' =>
array (size=1)
'{{ field }}' => string '"duration"' (length=10)
private 'plural' => null
private 'root' =>
array (size=4)
'token' => string 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' (length=64)
'languageCode' => string 'DE' (length=2)
'startDate' => string '2016-01-01' (length=10)
'endDate' => string '2016-01-05' (length=10)
private 'propertyPath' => string '[duration]' (length=10)
private 'invalidValue' => null
private 'constraint' =>
object(Symfony\Component\Validator\Constraints\Date)[136]
public 'message' => string 'This value is not a valid date.' (length=31)
public 'payload' => null
public 'groups' =>
array (size=1)
0 => string 'Default' (length=7)
private 'code' => string '2fa2158c-2a7f-484b-98aa-975522539ff8' (length=36)
private 'cause' => null
I don't see the any reason for that....
try to add parameter allowMissingFields
$constraint = new Assert\Collection([
'allowMissingFields' => true,
'fields' => [asserts...]
]);

Cannot access data passed in redirect

so i am using laravel 4.2. my problem is I cannot echo the data from my redirect route. how can i access it the right way? I tried searching to get the right answer but it didn't help me.
public function postLogin()
{
$timeIn = date('Y-m-d G:i:s');
$userLog = New UserLog;
$userLog->username = Input::get('username');
$userLog->time_in = $timeIn;
$userLog->save();
$users = $userLog;
return Redirect::route( 'account' )
->with( 'users', $users );
}
public function account(){
$data = Session::get('users');
var_dump($data );
echo $data->username;// this one throws an error
}
I can see that it has values in var_dump($data).
object(__PHP_Incomplete_Class)[92]
public '__PHP_Incomplete_Class_Name' => string 'UserLog' (length=7)
public 'timestamps' => boolean false
public 'table' => string 'userlogs' (length=8)
protected 'connection' => null
protected 'primaryKey' => string 'id' (length=2)
protected 'perPage' => int 15
public 'incrementing' => boolean true
protected 'attributes' =>
array (size=3)
'username' => string 'user' (length=4)
'time_in' => string '2015-07-28 15:11:43' (length=19)
'id' => int 240
protected 'original' =>
array (size=3)
'username' => string 'user' (length=4)
'time_in' => string '2015-07-28 15:11:43' (length=19)
'id' => int 240
these are my routes file
Route::get('/login', array(
'uses' => 'TimeController#login',
'as' => 'login')
);
Route::post('/postLogin', array(
'uses' => 'SessionsController#postLogin',
'as' => 'postLogin')
);
Route::get('/account', array(
'uses' => 'SessionsController#account',
'as' => 'account')
);
I felt like i made a huge success just by displaying the data, and the problem causing me to get errors is the __PHP_Incomplete_Class as you can see on my var_dump($data) above. To access the $data correctly, i need to unserialize it first before accessing the regular way. here i just added one line of code and everything works very well. thanks to this post unserializing.
public function account(){
$data = Session::get('users');
$data = unserialize(serialize($data)); //added code to unserialize the __PHP_Incomplete_Class
var_dump($data);
echo $data->username;
}
in my var_dump($data) the __PHP_Incomplete_Class is now gone
object(UserLog)[143]
public 'timestamps' => boolean false
protected 'table' => string 'userlogs' (length=8)
protected 'connection' => null
protected 'primaryKey' => string 'id' (length=2)
protected 'perPage' => int 15
public 'incrementing' => boolean true
protected 'attributes' =>
array (size=3)
'username' => string 'user' (length=4)
'time_in' => string '2015-07-28 19:57:08' (length=19)
'id' => int 276
protected 'original' =>
array (size=3)
'username' => string 'user' (length=4)
'time_in' => string '2015-07-28 19:57:08' (length=19)
'id' => int 276

Eloquent query correctly eager loads relation, but when I try to dump the related object I get only the ID

Hey guys I'm trying to grab a relation from the Friend model (pivot for user friends). When I try to dump the relation of the Friend object I should be getting a User model, instead it dumps only the ID of the User.
Here is the Friend Model:
class Friend extends Eloquent
{
public function requester()
{
return $this->belongsTo('Acme\Users\User', 'requester');
}
}
Here is friend repo:
public function getFriendRequests($id, $onlyAccepted = false)
{
return Friend::where('acceptor', $id)->with('requester')->get();
}
Here is FriendsController:
$friendAccepts = $this->friendRepo->getFriendAccepts(Auth::id(), true);
dd($friendAccepts[0]->acceptor);
It should be dumping a User object but I'm only getting the ID of the user when I do:
int 101
Here is output when I dd($friendAccepts[0]);
(It correctly shows the relation eager loaded as a User object
object(Acme\Friends\Friend)[513]
protected 'fillable' =>
array (size=5)
0 => string 'requester' (length=9)
1 => string 'acceptor' (length=8)
2 => string 'status' (length=6)
3 => string 'created_at' (length=10)
4 => string 'updated_at' (length=10)
protected 'table' => string 'friends' (length=7)
protected 'connection' => null
protected 'primaryKey' => string 'id' (length=2)
protected 'perPage' => int 15
public 'incrementing' => boolean true
public 'timestamps' => boolean true
protected 'attributes' =>
array (size=7)
'id' => int 1
'requester' => int 101
'acceptor' => int 1
'status' => int 2
'created_at' => string '2014-05-02 22:53:35' (length=19)
'updated_at' => string '2014-07-31 12:56:53' (length=19)
'deleted_at' => null
protected 'original' =>
array (size=7)
'id' => int 1
'requester' => int 101
'acceptor' => int 1
'status' => int 2
'created_at' => string '2014-05-02 22:53:35' (length=19)
'updated_at' => string '2014-07-31 12:56:53' (length=19)
'deleted_at' => null
protected 'relations' =>
array (size=1)
'acceptor' =>
object(Acme\Users\User)[318]
protected 'fillable' =>
array (size=10)
...
protected 'table' => string 'users' (length=5)
protected 'hidden' =>
array (size=2)
...
protected 'connection' => null
protected 'primaryKey' => string 'id' (length=2)
protected 'perPage' => int 15
public 'incrementing' => boolean true
public 'timestamps' => boolean true
protected 'attributes' =>
array (size=16)
...
protected 'original' =>
array (size=16)
...
protected 'relations' =>
array (size=0)
...
protected 'visible' =>
array (size=0)
...
protected 'appends' =>
array (size=0)
...
protected 'guarded' =>
array (size=1)
...
protected 'dates' =>
array (size=0)
...
protected 'touches' =>
array (size=0)
...
protected 'observables' =>
array (size=0)
...
protected 'with' =>
array (size=0)
...
protected 'morphClass' => null
public 'exists' => boolean true
protected 'pendingEvents' =>
array (size=0)
...
protected 'hidden' =>
array (size=0)
empty
protected 'visible' =>
array (size=0)
empty
protected 'appends' =>
array (size=0)
empty
protected 'guarded' =>
array (size=1)
0 => string '*' (length=1)
protected 'dates' =>
array (size=0)
empty
protected 'touches' =>
array (size=0)
empty
protected 'observables' =>
array (size=0)
empty
protected 'with' =>
array (size=0)
empty
protected 'morphClass' => null
public 'exists' => boolean true
protected 'pendingEvents' =>
array (size=0)
empty
UPDATE:
When I use toArray() and access acceptor as a keyed array element it dumps the user object's properties.
dd(Friend::where('requester', Auth::id())->with('acceptor')->first()->toArray()['acceptor'])
Output:
array (size=7)
'id' => int 1
'requester' => int 101
'acceptor' =>
array (size=14)
'id' => int 1
'email' => string 'nader.verla#johnston.com435' (length=27)
'fname' => string 'April' (length=5)
'lname' => string 'Macejkovic' (length=10)
'username' => string 'AprilMacejkovic40466' (length=20)
'birthday' => string '2006-12-02' (length=10)
'gender' => string 'Male' (length=4)
'location' => string 'Port Noelside' (length=13)
'website' => string 'pagacvandervort.net' (length=19)
'bio' => string 'Ut ut quia vitae vero. Sit eligendi voluptate quia. Voluptas ea accusamus fuga officiis sunt. Sed est fugiat et et voluptas. Distinctio vero error aliquid. Ipsam et tempora asperiores temporibus in autem.' (length=204)
'profile_picture' => string '' (length=0)
'created_at' => string '2013-10-18 09:49:31' (length=19)
'updated_at' => string '2014-03-05 04:17:24' (length=19)
'deleted_at' => null
'status' => int 2
'created_at' => string '2014-05-02 22:53:35' (length=19)
'updated_at' => string '2014-07-31 12:56:53' (length=19)
'deleted_at' => null
You may not want to have relationship methods named the same as table "attributes"(fields) if you plan on using dynamic properties to access those methods.
There is already a mechanism in place to resolve the dynamic properties and inaccesible properties using __get($key) which calls getAttribute($key). The first thing it checks for is if the key exists in the $attributes of the model instance and returns it if it does. This will stop it from continuing to check if there is a relation loaded with that name or if there is a method to call with a camel case version of that key.
"This allows every attribute to dynamically accessed through the _get method without accessors."
Ref
Eloquent Model API
Eloquent Model #__get
Eloquent Model #getAttribute

Get number of articles from a specific content category using Joomla functions

I'm struggling to get the number of articles from a specific category from my custom module? Would anyone mind pointing me in the correct direction as to what function I should use?
I've been using the following:
$model = JModelLegacy::getInstance('Articles', 'ContentModel');
$model->setState('filter_fields.catid', 16);
$articles = $model->getItems();
But I only get the following returned:
object(ContentModelArticles)[134]
protected 'cache' =>
array
empty
protected 'context' => string 'com_content.articles' (length=20)
protected 'filter_fields' =>
array
0 => string 'id' (length=2)
1 => string 'a.id' (length=4)
2 => string 'title' (length=5)
3 => string 'a.title' (length=7)
4 => string 'alias' (length=5)
5 => string 'a.alias' (length=7)
6 => string 'checked_out' (length=11)
7 => string 'a.checked_out' (length=13)
8 => string 'checked_out_time' (length=16)
9 => string 'a.checked_out_time' (length=18)
10 => string 'catid' (length=5)
11 => string 'a.catid' (length=7)
12 => string 'category_title' (length=14)
13 => string 'state' (length=5)
14 => string 'a.state' (length=7)
15 => string 'access' (length=6)
16 => string 'a.access' (length=8)
17 => string 'access_level' (length=12)
18 => string 'created' (length=7)
19 => string 'a.created' (length=9)
20 => string 'created_by' (length=10)
21 => string 'a.created_by' (length=12)
22 => string 'ordering' (length=8)
23 => string 'a.ordering' (length=10)
24 => string 'featured' (length=8)
25 => string 'a.featured' (length=10)
26 => string 'language' (length=8)
27 => string 'a.language' (length=10)
28 => string 'hits' (length=4)
29 => string 'a.hits' (length=6)
30 => string 'publish_up' (length=10)
31 => string 'a.publish_up' (length=12)
32 => string 'publish_down' (length=12)
33 => string 'a.publish_down' (length=14)
34 => string 'images' (length=6)
35 => string 'a.images' (length=8)
36 => string 'urls' (length=4)
37 => string 'a.urls' (length=6)
protected 'query' =>
array
empty
protected '__state_set' => null
protected '_db' =>
object(JDatabaseMySQLi)[15]
public 'name' => string 'mysqli' (length=6)
protected 'nameQuote' => string '`' (length=1)
protected 'nullDate' => string '0000-00-00 00:00:00' (length=19)
protected 'dbMinimum' => string '5.0.4' (length=5)
private '_database' (JDatabase) => string 'xxxx' (length=25)
protected 'connection' =>
object(mysqli)[16]
public 'affected_rows' => null
public 'client_info' => null
public 'client_version' => null
public 'connect_errno' => null
public 'connect_error' => null
public 'errno' => null
public 'error' => null
public 'field_count' => null
public 'host_info' => null
public 'info' => null
public 'insert_id' => null
public 'server_info' => null
public 'server_version' => null
public 'sqlstate' => null
public 'protocol_version' => null
public 'thread_id' => null
public 'warning_count' => null
protected 'count' => int 0
protected 'cursor' =>
object(mysqli_result)[202]
public 'current_field' => null
public 'field_count' => null
public 'lengths' => null
public 'num_rows' => null
public 'type' => null
protected 'debug' => boolean false
protected 'limit' => int 0
protected 'log' =>
array
empty
protected 'offset' => int 0
protected 'sql' =>
object(JDatabaseQueryMySQLi)[258]
protected 'db' =>
&object(JDatabaseMySQLi)[15]
protected 'type' => string 'select' (length=6)
protected 'element' => null
protected 'select' =>
object(JDatabaseQueryElement)[257]
protected 'name' => string 'SELECT' (length=6)
protected 'elements' =>
array
0 => string 'm.id, m.title, m.module, m.position, m.content, m.showtitle, m.params, mm.menuid' (length=80)
protected 'glue' => string ',' (length=1)
protected 'delete' => null
protected 'update' => null
protected 'insert' => null
protected 'from' =>
object(JDatabaseQueryElement)[259]
protected 'name' => string 'FROM' (length=4)
protected 'elements' =>
array
0 => string '#__modules AS m' (length=15)
protected 'glue' => string ',' (length=1)
protected 'join' =>
array
0 =>
object(JDatabaseQueryElement)[260]
protected 'name' => string 'LEFT JOIN' (length=9)
protected 'elements' =>
array
0 => string '#__modules_menu AS mm ON mm.moduleid = m.id' (length=43)
protected 'glue' => string ',' (length=1)
1 =>
object(JDatabaseQueryElement)[262]
protected 'name' => string 'LEFT JOIN' (length=9)
protected 'elements' =>
array
0 => string '#__extensions AS e ON e.element = m.module AND e.client_id = m.client_id' (length=72)
protected 'glue' => string ',' (length=1)
protected 'set' => null
protected 'where' =>
object(JDatabaseQueryElement)[261]
protected 'name' => string 'WHERE' (length=5)
protected 'elements' =>
array
0 => string 'm.published = 1' (length=15)
1 => string 'e.enabled = 1' (length=13)
2 => string '(m.publish_up = '0000-00-00 00:00:00' OR m.publish_up <= '2013-10-07 14:10:50')' (length=79)
3 => string '(m.publish_down = '0000-00-00 00:00:00' OR m.publish_down >= '2013-10-07 14:10:50')' (length=83)
4 => string 'm.access IN (1,1)' (length=17)
5 => string 'm.client_id = 0' (length=15)
6 => string '(mm.menuid = 113 OR mm.menuid <= 0)' (length=35)
protected 'glue' => string ' AND ' (length=5)
protected 'group' => null
protected 'having' => null
protected 'columns' => null
protected 'values' => null
protected 'order' =>
object(JDatabaseQueryElement)[264]
protected 'name' => string 'ORDER BY' (length=8)
protected 'elements' =>
array
0 => string 'm.position, m.ordering' (length=22)
protected 'glue' => string ',' (length=1)
protected 'union' => null
protected 'autoIncrementField' => null
protected 'tablePrefix' => string 'joomla_' (length=7)
protected 'utf' => boolean true
protected 'errorNum' => int 0
protected 'errorMsg' => string '' (length=0)
protected 'hasQuoted' => boolean false
protected 'quoted' =>
array
empty
protected 'name' => string 'articles' (length=8)
protected 'option' => string 'com_content' (length=11)
protected 'state' =>
object(JObject)[279]
protected '_errors' =>
array
empty
public 'filter_fields.catid' => int 16
protected 'event_clean_cache' => string 'onContentCleanCache' (length=19)
protected '_errors' =>
array
empty
I changed my code to the following:
$model = JModelLegacy::getInstance('Articles', 'ContentModel');
$model->setState('filter.category_id', 16);
$articles = $model->getItems();
$num_articles = count($articles);

Magento Category model not loading all data

I am building a custom navigation menu in Magento which displays the categories from a different store with a different root category from the current store. Some of the categories should be hidden as they have 'Include in Navigation Menu' set to No.
It should be possible to read this attribute from the category model as in this question: How do I detect if a category has Include in Navigation Menu set to NO?
However $category->getIncludeInMenu() is returning NULL for all categories on my Magento EE 1.11 installation.
// Load child categories for a specific root category
$_uk_default_root_id = Mage::app()->getStore('uk_default')->getRootCategoryId();
$_uk_default_root_category = Mage::getModel('catalog/category')->load($_uk_default_root_id);
$_sub_categories = $_uk_default_root_category->getChildrenCategories();
// Loop through the categories
foreach ($_sub_categories as $_category)
{
if ($_category->getIsActive() && $_category->getIncludeInMenu())
{
<echo navigation link>
}
}
A var dump of one of the categories shows no 'include_in_menu' attribute, although the 'is_active' attribute works as expected. Is there an alternative way to determine if a category should be displayed in the navigation?
Var dump of category object:
object(Mage_Catalog_Model_Category)[423]
protected '_eventPrefix' => string 'catalog_category' (length=16)
protected '_eventObject' => string 'category' (length=8)
protected '_cacheTag' => string 'catalog_category' (length=16)
protected '_useFlatResource' => boolean false
private '_designAttributes' =>
array (size=6)
0 => string 'custom_design' (length=13)
1 => string 'custom_design_from' (length=18)
2 => string 'custom_design_to' (length=16)
3 => string 'page_layout' (length=11)
4 => string 'custom_layout_update' (length=20)
5 => string 'custom_apply_to_products' (length=24)
protected '_treeModel' => null
protected '_defaultValues' =>
array (size=0)
empty
protected '_storeValuesFlags' =>
array (size=0)
empty
protected '_lockedAttributes' =>
array (size=0)
empty
protected '_isDeleteable' => boolean true
protected '_isReadonly' => boolean false
protected '_resourceName' => string 'catalog/category' (length=16)
protected '_resource' => null
protected '_resourceCollectionName' => string 'catalog/category_collection' (length=27)
protected '_dataSaveAllowed' => boolean true
protected '_isObjectNew' => null
protected '_data' =>
array (size=15)
'entity_id' => string '16' (length=2)
'entity_type_id' => string '3' (length=1)
'attribute_set_id' => string '3' (length=1)
'parent_id' => string '15' (length=2)
'created_at' => string '2011-11-16 12:16:27' (length=19)
'updated_at' => string '2011-12-19 16:19:08' (length=19)
'path' => string '1/15/16' (length=7)
'position' => string '1' (length=1)
'level' => string '2' (length=1)
'children_count' => string '8' (length=1)
'is_active' => string '1' (length=1)
'request_path' => null
'name' => string 'Vacuum Cleaners' (length=15)
'url_key' => string 'vacuum-cleaners' (length=15)
'is_anchor' => string '1' (length=1)
protected '_hasDataChanges' => boolean true
protected '_origData' =>
array (size=15)
'entity_id' => string '16' (length=2)
'entity_type_id' => string '3' (length=1)
'attribute_set_id' => string '3' (length=1)
'parent_id' => string '15' (length=2)
'created_at' => string '2011-11-16 12:16:27' (length=19)
'updated_at' => string '2011-12-19 16:19:08' (length=19)
'path' => string '1/15/16' (length=7)
'position' => string '1' (length=1)
'level' => string '2' (length=1)
'children_count' => string '8' (length=1)
'is_active' => string '1' (length=1)
'request_path' => null
'name' => string 'Vacuum Cleaners' (length=15)
'url_key' => string 'vacuum-cleaners' (length=15)
'is_anchor' => string '1' (length=1)
protected '_idFieldName' => string 'entity_id' (length=9)
protected '_isDeleted' => boolean false
protected '_oldFieldsMap' =>
array (size=0)
empty
protected '_syncFieldsMap' =>
array (size=0)
empty
This is due to Magento lazy loading the category model. The getChildrenCategories() method on the Mage_Catalog_Model_Category model returns a collection of category models and Magento only loads the core model data rather than the additional EAV data for each model. The include_in_menu attribute is stored in the EAV data store and has not been loaded.
Each category can be forced to load by calling $_category->load(); which will force Magento to load the additional EAV data for each category.
// Loop through the categories
foreach ($_sub_categories as $_category)
{
$_category->load();
if ($_category->getIsActive() && $_category->getIncludeInMenu())
{
<echo navigation link>
}
}
This changes the _data array from this:
array (size=15)
'entity_id' => string '16' (length=2)
'entity_type_id' => string '3' (length=1)
'attribute_set_id' => string '3' (length=1)
'parent_id' => string '15' (length=2)
'created_at' => string '2011-11-16 12:16:27' (length=19)
'updated_at' => string '2011-12-19 16:19:08' (length=19)
'path' => string '1/15/16' (length=7)
'position' => string '1' (length=1)
'level' => string '2' (length=1)
'children_count' => string '8' (length=1)
'is_active' => string '1' (length=1)
'request_path' => null
'name' => string 'Vacuum Cleaners' (length=15)
'url_key' => string 'vacuum-cleaners' (length=15)
'is_anchor' => string '1' (length=1)
To this:
array (size=33)
'entity_id' => string '16' (length=2)
'entity_type_id' => string '3' (length=1)
'attribute_set_id' => string '3' (length=1)
'parent_id' => string '15' (length=2)
'created_at' => string '2011-11-16 12:16:27' (length=19)
'updated_at' => string '2011-12-19 16:19:08' (length=19)
'path' => string '1/15/16' (length=7)
'position' => string '1' (length=1)
'level' => string '2' (length=1)
'children_count' => string '8' (length=1)
'is_active' => string '1' (length=1)
'request_path' => null
'name' => string 'Vacuum Cleaners' (length=15)
'url_key' => string 'vacuum-cleaners' (length=15)
'is_anchor' => string '1' (length=1)
'meta_title' => null
'display_mode' => string 'PRODUCTS' (length=8)
'custom_design' => null
'page_layout' => null
'url_path' => string 'vacuum-cleaners' (length=15)
'image' => string 'heading_vacuums_1.png' (length=21)
'include_in_menu' => string '1' (length=1)
'landing_page' => null
'custom_use_parent_settings' => string '0' (length=1)
'custom_apply_to_products' => string '0' (length=1)
'filter_price_range' => null
'description' => null
'meta_keywords' => null
'meta_description' => null
'custom_layout_update' => null
'available_sort_by' => null
'custom_design_from' => null
'custom_design_to' => null
Which includes the include_in_menu attribute.
You have to use:
$_category->load($_category->getId());
worked for me ;)

Resources