0

I have a custom module for batch order in my magento application. I have created another store view and the batch order form will need to have different products in each store.

Here is part of the code that's responsible for the tabs is my order form. The content of the tab can be set in the admin panel.

Updated:

// Gets the block data.
$groups = $this->getGroups();
$mySelectedGroups = array('2', '4'); // this is the group entity_id from database


<!-- tab navigation -->
                <ul id="tabs" class="nav nav-tabs">
                    <?php
                    // Loops through the groups to get their name as nav heading.
                    // The first iteration will activate the tab for the first group.
                    $navI = 1;
                    foreach ($groups as $group) :
                        if (in_array($group, $mySelectedGroups))
                        if ($group->hasProducts()) { ?>
                            <li <?php if ($navI == 1) { ?> class="active" <?php } ?>>
                                <a href="#<?php echo $group->getId(); ?>"
                                   data-toggle="tab">
                                    <?php echo $group->getName(); ?>
                                    &nbsp;<i style="display: none;" class="text-danger error_glyph_<?php echo $group->getId(); ?> fa fa-exclamation-circle" aria-hidden="true"></i>
                                </a>
                            </li>
                            <?php $navI++;
                        } endforeach; ?>
                </ul>
                <!-- ./ tab navigation -->

It pulls all the groups of products created in the admin. Can you tell me a way of calling them here 1 by 1 instead of bulk action?

I will then be able to set them manually for each store view.

Update:

That's the getData() for $groups: enter image description here

It doesn't look like a normal array...

enter image description here

That's what the original looks like.

enter image description here

Here is the back end setting for it.

1 Answer 1

0

I don't know if this is exactly what you want but if you want to set the groups manually, you have to put them in an array something like this:

$groups = array('group1', 'group2', ...);

foreach ($groups as $group) :
...

EDIT:

$groups = $this->getGroups(); // your groups
$mySelectedGroups = array('group1', 'group2', ...);

foreach($group as $group) {
    if (in_array($group, $mySelectedGroups)) {
    //...
    }
}

EDIT 2 you have an error in your code

<?php
$groups = $this->getGroups();
$mySelectedGroups = array('1403', '1404', '1405'); // this is the group entity_id from database
?>

<!-- tab navigation -->
<ul id="tabs" class="nav nav-tabs">
    <?php 
    $navI = 1;
    foreach ($groups as $group) :
        if (in_array($group, $mySelectedGroups)):
            if ($group->hasProducts()): ?>
                <li <?php if ($navI == 1) { ?> class="active" <?php } ?> >
                    <a href="#<?php echo $group->getId(); ?>"
                       data-toggle="tab">
                        <?php echo $group->getName(); ?>
                        &nbsp;<i style="display: none;" class="text-danger error_glyph_<?php echo $group->getId(); ?> fa fa-exclamation-circle" aria-hidden="true"></i>
                    </a>
                </li>
                <?php $navI++; ?>
            <?php endif; ?>
        <?php endif; ?>
    <?php endforeach; ?>
</ul>
14
  • Well, this is how my navigation is created. All I want, is to select what groups to include within my navigation tab. For now all of the groups created in the backend are being displayed.
    – Greg
    Commented Aug 7, 2017 at 12:36
  • I have this: $groups = $this->getGroups(); so it pulls all the groups but I am not sure what it pulls... Is this ID?
    – Greg
    Commented Aug 7, 2017 at 12:39
  • look my update please
    – PЯINCƎ
    Commented Aug 7, 2017 at 12:50
  • No navigation is being displayed now, is there anyway of finding out what groups names are being pulled in here $groups = $this->getGroups();? It would make it easier for me to find out what to put in the array.
    – Greg
    Commented Aug 7, 2017 at 13:01
  • you should put in $mySelectedGroups the real groups ! , try var_dump($groups) or var_dump($groups->getData())
    – PЯINCƎ
    Commented Aug 7, 2017 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.