hay i have result like this
But i want to remove duplicates keterangan and just display one data , i expected like this
keterangan is unique so just display one data , how do like this ?
this is my controllers
public function print_cashier($id)
{
$get_allData = $this->Approval_management_model->getDataCashier($id);
$data['resultsAll'] = $get_allData;
}
method getDataCashier() from query like this :
function getDataCashier($id)
{
$this->db->select(',
a.jenis_jurnal,
a.no_perkiraan,
c.nama,
a.keterangan,
b.potongan,
b.potongan_note,
b.coa_potongan,
b.coa_lain,
b.biaya_lain_note,
a.debet,
a.kredit,
d.username');
$this->db->from('jurnal a');
$this->db->join('tr_new_purchase_order_payment as b', 'a.no_request=b.no_request', 'left');
$this->db->join('coa_master as c', 'a.no_perkiraan=c.no_perkiraan', 'left');
$this->db->join('users as d', 'b.created_by=d.id_user', 'left');
$this->db->where('a.jenis_jurnal', 'pembayaran');
$this->db->where('b.id', $id);
$query = $this->db->get()->result();
}
this is result form var_dump($data['resultsAll'])
array (size=5)
0 =>
object(stdClass)[40]
public 'keterangan' => string 'PEMBELIAN Cash Advance U/CA-2020-0045 TGL PR. 2020-12-31' (length=56)
public 'jenis_jurnal' => string 'pembayaran' (length=10)
public 'no_perkiraan' => string '1101-01-01' (length=10)
public 'nama' => string 'Kas Kecil - GA' (length=14)
public 'potongan' => string '10000' (length=5)
public 'potongan_note' => string 'bbbbb' (length=5)
public 'coa_potongan' => string '7204-02-01' (length=10)
public 'coa_lain' => string '7206-01-01' (length=10)
public 'biaya_lain_note' => string 'bbb' (length=3)
public 'debet' => string '0' (length=1)
public 'kredit' => string '-9998' (length=5)
public 'username' => string 'Firman' (length=6)
1 =>
object(stdClass)[41]
public 'keterangan' => string 'PEMBELIAN Cash Advance U/CA-2020-0045 TGL PR. 2020-12-31' (length=56)
public 'jenis_jurnal' => string 'pembayaran' (length=10)
public 'no_perkiraan' => string '7204-02-01' (length=10)
public 'nama' => string 'Provisi Bank' (length=12)
public 'potongan' => string '10000' (length=5)
public 'potongan_note' => string 'bbbbb' (length=5)
public 'coa_potongan' => string '7204-02-01' (length=10)
public 'coa_lain' => string '7206-01-01' (length=10)
public 'biaya_lain_note' => string 'bbb' (length=3)
public 'debet' => string '0' (length=1)
public 'kredit' => string '10000' (length=5)
public 'username' => string 'Firman' (length=6)
2 =>
object(stdClass)[42]
public 'keterangan' => string 'PEMBELIAN Cash Advance U/CA-2020-0045 TGL PR. 2020-12-31' (length=56)
public 'jenis_jurnal' => string 'pembayaran' (length=10)
public 'no_perkiraan' => string '2105-02-01' (length=10)
public 'nama' => string 'Hutang PPH 21 Pegawai' (length=21)
public 'potongan' => string '10000' (length=5)
public 'potongan_note' => string 'bbbbb' (length=5)
public 'coa_potongan' => string '7204-02-01' (length=10)
public 'coa_lain' => string '7206-01-01' (length=10)
public 'biaya_lain_note' => string 'bbb' (length=3)
public 'debet' => string '0' (length=1)
public 'kredit' => string '10000' (length=5)
public 'username' => string 'Firman' (length=6)
3 =>
object(stdClass)[43]
public 'keterangan' => string 'PEMBELIAN Cash Advance U/CA-2020-0045 TGL PR. 2020-12-31' (length=56)
public 'jenis_jurnal' => string 'pembayaran' (length=10)
public 'no_perkiraan' => string '7206-01-01' (length=10)
public 'nama' => string 'Biaya Lainnya' (length=13)
public 'potongan' => string '10000' (length=5)
public 'potongan_note' => string 'bbbbb' (length=5)
public 'coa_potongan' => string '7204-02-01' (length=10)
public 'coa_lain' => string '7206-01-01' (length=10)
public 'biaya_lain_note' => string 'bbb' (length=3)
public 'debet' => string '10000' (length=5)
public 'kredit' => string '0' (length=1)
public 'username' => string 'Firman' (length=6)
4 =>
object(stdClass)[44]
public 'keterangan' => string 'PEMBELIAN Cash Advance U/CA-2020-0045 TGL PR. 2020-12-31' (length=56)
public 'jenis_jurnal' => string 'pembayaran' (length=10)
public 'no_perkiraan' => string '6204-03-01' (length=10)
public 'nama' => string 'Pemeliharaan Peralatan' (length=22)
public 'potongan' => string '10000' (length=5)
public 'potongan_note' => string 'bbbbb' (length=5)
public 'coa_potongan' => string '7204-02-01' (length=10)
public 'coa_lain' => string '7206-01-01' (length=10)
public 'biaya_lain_note' => string 'bbb' (length=3)
public 'debet' => string '2' (length=1)
public 'kredit' => string '0' (length=1)
public 'username' => string 'Firman' (length=6)
when use group_by just return one data for all column ,,
help. thanks
Im from Indonesian and i khow that is like a general journal a part of Indonesian Accounting Standar. I see you want to show a journal, right? Or you want to show a ledger for Pemeliharaan Mobil?
I think you miss some extra table for some relation.
Try this :
Controller :
public function print_cashier($id)
{
$get_allData = $this->Approval_management_model->getDataCashier($id);
$get_oneData = $this->Approval_management_model->getDataCashierOne($id);
$data['resultsAll'] = $get_allData;
$data['resultsOne'] = $get_oneData; // Get one row
}
In Model, add this method :
function getDataCashierOne($id)
{
$this->db->select(',
a.no_perkiraan,c.nama,a.keterangan,
b.coa_lain,b.biaya_lain_note,
d.username');
$this->db->from('jurnal a');
$this->db->join('tr_new_purchase_order_payment as b',
'a.no_request=b.no_request', 'left');
$this->db->join('coa_master as c', 'a.no_perkiraan=c.no_perkiraan', 'left');
$this->db->join('users as d', 'b.created_by=d.id_user', 'left');
$this->db->where('a.jenis_jurnal', 'pembayaran');
$this->db->where('b.id', $id);
$query = $this->db->get()->row();
}
In View :
<div class = "row"> <!-- If Bootstrap -->
<div class = "col-md-2">
<?php foreach($resultAll as $all){
echo $all->no_perkiraan;
}?>
</div>
<div class = "col-md-2">
<?php foreach($resultAll as $all){
echo $all->nama;
}?>
</div>
<div class = "col-md-6">
<?php // This is one row data
echo $one->keterangan;
?>
</div>
<div class = "col-md-4">
<?php foreach($resultAll as $all){
echo $all->debet;
// kredit field and also tugas field here
// Use span class or your css class for layout
}?>
</div>
</div>
Related
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]
],
]);
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
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);
I'm using the package: https://packagist.org/packages/gavroche/ups-api
I'm getting some odd behaviors from Laravels Exception Handler when I run this:
$tracking = new \UPS\Tracking(
'KEY', 'USERNAME', 'PASS'
);
$shipment = $tracking->track('TRACKING NUMBER HERE');
foreach($shipment->Package->Activity as $activity) {
var_dump($activity->ActivityLocation->Address->City);
}
The interesting thing is the cities are var_dumped however laravels exception handler, in the same breath, says Undefined property: stdClass::$City.
Here is a vardump of one of the $activity objects:
object(stdClass)[518]
public 'ActivityLocation' =>
object(stdClass)[519]
public 'Address' =>
object(stdClass)[520]
public 'City' => string 'CLEVELAND' (length=9)
public 'StateProvinceCode' => string 'TN' (length=2)
public 'PostalCode' => string '37311' (length=5)
public 'CountryCode' => string 'US' (length=2)
public 'Code' => string 'M4' (length=2)
public 'Description' => string 'RECEPTION' (length=9)
public 'SignedForByName' => string 'HICKMAN' (length=7)
public 'Status' =>
object(stdClass)[521]
public 'StatusType' =>
object(stdClass)[522]
public 'Code' => string 'D' (length=1)
public 'Description' => string 'DELIVERED' (length=9)
public 'StatusCode' =>
object(stdClass)[523]
public 'Code' => string 'KB' (length=2)
public 'Date' => string '20130426' (length=8)
public 'Time' => string '085500' (length=6)
Any property in the $activity->ActivityLocation->Address object laravel sees issue with. However, I can request $activity->Status->StatusType->Description and there are no problems.
A regular for loop fixes the issue. Seems to be some issue in the incrementing of php's foreach().
for ($i=0; $i < (count($shipment->Package->Activity) - 1); $i++) {
var_dump($shipment->Package->Activity[$i]->ActivityLocation->Address->City);
}
You were not clear on this, but are you trying to access this as
$activity->ActivityLocation->Address->City ?
You left the $activity part off your question and used $City and not City, and I wasnt sure if this was intentional or not
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 ;)