Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How to retrieve a specific website? 
 
Emperor
Sr. Member
 
Total Posts:  111
Joined:  2007-08-31
 

The file “template\dashboard\store\switcher.phtml” in the admin template folder return a listing of all the websites and stores to select from to view information.

the code is as follows:

<class="switcher"><label for="store_switcher"><?php echo $this->__('View Statistics for'?>:</label>
<
select name="store_switcher" id="store_switcher" class="left-col-block" onchange="return switchStore(this);">
    <
option value=""><?php echo $this->__('All Websites'?></option>
    
    
<?php foreach ($this->getWebsiteCollection() as $_website): ?>


        <?php $showWebsite
=false?>
        <?php 
foreach ($this->getGroupCollection($_website) as $_group): ?>
            <?php $showGroup
=false?>
            <?php 
foreach ($this->getStoreCollection($_group) as $_store): ?>
                <?php 
if ($showWebsite == false): ?>
                    <?php $showWebsite 
true?>
                    
<option website="true" value="<?php echo $_website->getId() ?>"<?php if($this->getRequest()->getParam('website') == $_website->getId()): ?> selected="selected"<?php endif; ?>><?php echo $_website->getName() ?></option>
                
<?php endif; ?>
                <?php 
if ($showGroup == false): ?>
                    <?php $showGroup 
true?>
                    
<!--optgroup label="&nbsp;&nbsp;&nbsp;<?php echo $_group->getName() ?>"-->
                    <
option group="true" value="<?php echo $_group->getId() ?>"<?php if($this->getRequest()->getParam('group') == $_group->getId()): ?> selected="selected"<?php endif; ?>>&nbsp;&nbsp;&nbsp;<?php echo $_group->getName() ?></option>
                
<?php endif; ?>
                
<option value="<?php echo $_store->getId() ?>"<?php if($this->getStoreId() == $_store->getId()): ?> selected="selected"<?php endif; ?>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $_store->getName() ?></option>
            
<?php endforeach; ?>
            <?php 
if ($showGroup): ?>
                
<!--</optgroup>-->
            
<?php endif; ?>
        <?php 
endforeach; ?>
    <?php 
endforeach; ?>
</select>
</
p>

What I want to do is to show only a particular website based on the website ID.

So instead of using $this->getWebsiteCollection() to retrieve all the websites created and their respective stores, I want to retrieve only a particular website and it’s respective stores based on the website ID. For e.g:

select ‘website_id’ from .... where id = 1

Can anybody help me out with this?

Please.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Emperor
Sr. Member
 
Total Posts:  111
Joined:  2007-08-31
 

Can somebody please help me with this.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Emperor
Sr. Member
 
Total Posts:  111
Joined:  2007-08-31
 

Still no answer!

Alright then. Can someone help me then with the code I could use to fetch all website ids?

 
Magento Community Magento Community
Magento Community
Magento Community
 
retif
Sr. Member
 
Total Posts:  171
Joined:  2008-08-16
Odessa, Ukraine
 

Mage::app()->getWebsite()->getId();
use it in your first post code instead of
foreach ($this->getWebsiteCollection() as $_website):
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top