Magento: Storeview Access - magento

Situation right now:
I've got a live-system and its running very well.
I DO NOT have a testing system.
Our live-system is a multi-store with several storeviews on one website.
PROBLEM:
I need to to add one more storeview and work on that within that livesystem. How can I restrict access to this storeview, so that no customer, whether logged in or not, can see this store? Is this even possible?
I need just an admin (me) to access this storeview.
Sure, I could disable all storeswitcher in the other live-stores but I don't think, this would be a nice solution to my problem. :)

If you do not want to show up currently edited store (view) on your language dropdown select field, do the following:
Add a new customer-group called "admins" to your shop and remember the id which appears in the list.
If not already done, add a new customer for the admin and assign it to the just created customer-group
Go to system->store-view and click on the link in the StoreView Name - column which you dont want to show up on the frontend and klick it, you'll see the StoreView id in the url /index.php/admin/system_store/editStore/store_id/3/key/, remember it
Now edit the file: app/design/frontend/default/your_shop/template/page/switch/languages.phtml
from:
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<label for="select-language"><?php echo $this->__('Your Language:') ?></label>
<select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value">
<?php foreach ($this->getStores() as $_lang): ?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
<option value="<?php echo $_lang->getCurrentUrl() ?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>
to:
<?php
// StoreView-Ids we dont want to show on frontend
$stores = array(3);
// Set admin group id with access to the above storeviews
$frontendAdminGroupId = 5;
// Get current user group id
$currentGroupId = $this->helper('customer')->getCurrentCustomer()->group_id;
?>
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<label for="select-language"><?php echo $this->__('Your Language:') ?></label>
<select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value">
<?php foreach ($this->getStores() as $_lang): ?>
<?php foreach ($stores as $_adminStore) : ?>
<?php /* Admin Store! */?>
<?php if($_adminStore == $_lang->getId() ) : ?>
<?php if($currentGroupId == $frontendAdminGroupId) : ?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
<option value="<?php echo $_lang->getCurrentUrl() ?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>
<?php endif; ?>
<?php else: ?>
<?php /* Normal User! */?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
<option value="<?php echo $_lang->getCurrentUrl() ?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>
<?php endif; ?>
<?php endforeach; ?>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>
you also have to edit the checkout and any other part of magento which shows up a select field for the store view, that's just a half solution. good luck :-)

If you use Magento Enterprise you are given a staging site where you would be able to make these changes before pushing them out to production.
Or, you can do as #Anton S above said and create a development site. You would use Magento's export functionality to move changes over. NOT a full database dump/import. That way you won't lose any customer and order information.

Related

How to make dropdown layered navigation in Magento 2

I'm figuring out about Magento 2 layered navigation. I want to make this navigation with dropdown lists.
I try this code:
<select onchange="setLocation(this.value)">
<option value=""><?php echo 'Choose an Option...' ?></option>
<?php foreach ($this->getItems() as $_item): ?>
<option
<?php if ($_item->getCount() > 0): ?>
value="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?>
<?php else: echo '>' . $_item->getLabel() ?>
<?php endif; ?>
(<?php echo $_item->getCount() ?>)
</option>
<?php endforeach ?>
</select>
but I am getting the error "setLocation(this.value) is not defined". If anyone has another option, please let me know.
Please add below js code:
function setLocation(value) {
window.location = value;
}

how to display size attribute of simple product in bundle product

I created bundle products it displays name + price of products, however i want to display size of simple products not name and price. How can i enable Magento to display size attribute on simple products? Thanks in advance.
Step1:- Find below file in your theme.
app\design\frontend{{your theme}}\default\template\bundle\catalog\product\view\type\bundle\option/select.phtml
Step2:-
Please find below code in above file
<?php foreach ($_selections as $_selection): ?>
<?php if ($_selection->getSelectionCanChangeQty() && $this->_isSelected($_selection)): ?>
<?php $tierPriceHtml = $this->getTierPriceHtml($_selection); ?>
<?php endif; ?>
<option value="<?php echo $_selection->getSelectionId() ?>"<?php if ($this->_isSelected($_selection)) echo ' selected="selected"' ?><?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>><?php echo $this->getSelectionTitlePrice($_selection, false) ?></option>
<?php endforeach; ?>
Replace with this code
<?php foreach ($_selections as $_selection): ?>
**<?php $productLoad=Mage::getModel('catalog/product')->load($_selection->getId()); ?>**
<?php if ($_selection->getSelectionCanChangeQty() && $this->_isSelected($_selection)): ?>
<?php $tierPriceHtml = $this->getTierPriceHtml($_selection); ?>
<?php endif; ?>
<option value="<?php echo $_selection->getSelectionId() ?>"<?php if ($this->_isSelected($_selection)) echo ' selected="selected"' ?><?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>><?php echo $productLoad->getAttributeText('size'); ?></option>
<?php endforeach; ?>

Magento language switcher how to show unselected language

Please I need your help to show unselected language instead of the selected.
in other words, if you open default language (English) will load and in the top bar will show English to click on it to change to French so i need to show French if the store using English view and same if using French view will show English in topbar.
<?php if(count($this->getStores())>1): ?>
<div class="form-language top-select">
<select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value" style="width:auto;">
<?php foreach ($this->getStores() as $_lang): ?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
<option value="<?php echo $_lang->getCurrentUrl() ?>" <?php if($lang_flag): ?> data-image="<?php echo $this->getSkinUrl('images/flags/'.$_lang->getCode().'.png'); ?>" <?php endif; ?> <?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>
<?php endforeach; ?>
</select>
<script type="text/javascript">
(function($){
$("#select-language").selectbox();
})(jQuery);
</script>
</div>
<?php endif; ?>

Replace default "Choose an Option" text in Magento layered navigation dropdown

I am using dropdowns to display my layered navigation attribute values. I have 3 filters - price, size and color.
This is what I am trying to do:
1. Get dropdowns for the layered navigation filters.
2. Get the attribute label/name to show up as the first option. Currently, my code puts a default "Choose an Option" value for each dropdown, which I would like to replace with something like "Choose Price", "Choose Size" and "Choose Color".
Here is my current code for template/catalog/layer/filter.phtml. The dropdown works, but I am stuck at getting the attribute label instead of "Choose an Option"
<select onchange="setLocation(this.value)">
<option value='' disabled selected style='display:none;'>Choose an Option</option>
</option>
<?php foreach ($this->getItems() as $_item): ?>
<option
<?php if ($_item->getCount() > 0): ?>
value="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?>
<?php else: echo '>' . $_item->getLabel() ?>
<?php endif; ?>
(<?php echo $_item->getCount() ?>)
</option>
Try this code. It is tested in all the browsers.
<select onchange="setLocation(this.value)">
<?php $count = 0; ?>
<?php foreach ($this->getItems() as $_item): ?>
<?php $count++; ?>
<?php if($count == 1): ?>
<option value='' disabled selected style='display:none;'>Choose <?php echo $attribute_code = $_item->getFilter()->getName();?> </option>
<?php endif; ?>
<option <?php if ($_item->getCount() > 0): ?> value="<?php echo $this->urlEscape($_item->getUrl()) ?>">
<?php echo $_item->getLabel() ?> <?php else: echo '>' . $_item->getLabel() ?> <?php endif; ?> (<?php echo $_item->getCount() ?>) </option>
<?php endforeach; ?>
</select>

Change gender dropdown to radio button in magento

Today i started working in registration form in magento site. As you know by default it's having gender drop down. I need to change that to checkbox.
So far i went to register.phtml file, and tried to add <input type="radio" ...../> select files, but this didn't worked.
Did anyone know how to solve this !
please give me some suggestions to so this....
Do not forget the validation!
<div class="input-box">
<?php
$options = Mage::getResourceSingleton('customer/customer')->getAttribute('gender')->getSource()->getAllOptions();
$value = $this->getGender();
$_last = count($options);
$_index = 0;
?>
<?php foreach ($options as $option):?>
<?php if($option['value'] != ''): ?>
<input id="<?php echo $this->getFieldId('gender')?>-<?php echo $option['value'] ?>"
class="radio<?php if ($this->isRequired() && $_index == $_last - 1):?> validate-one-required<?php endif; ?>"
type="radio" title="<?php echo $option['label'] ?>"
value="<?php echo $option['value'] ?>" name="<?php echo $this->getFieldName('gender')?>"
<?php if ($option['value'] == $value) echo ' checked="checked"' ?>>
<label for="<?php echo $this->getFieldId('gender')?>-<?php echo $option['value'] ?>">
<?php echo $option['label'] ?>
</label>
<?php endif; ?>
<?php $_index++; ?>
<?php endforeach;?>
</div>
Magento uses widgets on registration form. In fact in template register.phtml you can see lines:
<?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
<?php if ($_gender->isEnabled()): ?>
<li><?php echo $_gender->setGender($this->getFormData()->getGender())->toHtml() ?></li>
<?php endif ?>
This particular widget can be found in template/customer/widget directory. So in order to change select into radio buttons, copy it (template) to your theme and modify, e.g.:
<div class="input-box">
<label><?php echo $this->__('Gender'); ?></label>
<?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute('gender')->getSource()->getAllOptions();?>
<?php $value = $this->getGender();?>
<?php foreach ($options as $option):?>
<input type="radio" name="<?php echo $this->getFieldName('gender')?>" value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $value) echo ' selected="selected"' ?> /><?php echo $option['label'] ?>
<br />
<?php endforeach;?>
</div>
Hope didn't make any typo.

Resources