Hide text from one magento store - magento

I have two stores created, retail and wholesale. I created a static block visible in both the stores. Without logging in, i want to hide a line when somebody opens the wholesale page using css display:none.
I need to a php code that would detect different stores so i can add css class. I've seen examples for logged in users but not for stores.
Example code that i'm looking for:
<?php
if (store = wholesale) then
else if…
end if
?>
Anyone?

use this
$storeCode = Mage::app()->getStore()->getCode();
if($storeCode == 'default')
{
/* your code here */
};

You can apply store condition as per below :
if (Mage::app()->getStore()->getId() == YOUR STORE VIEW ID HERE)
{
//apply your custom code here
}
or
if (Mage::app()->getStore()->getCode() == YOUR STORE VIEW CODE HERE)
{
//apply your custom code here
}
Apply your store id or code and put them in condition accordingly.

Related

Magento 2 How to pass js variable to controller and then call template with custom code?

I need dynamically change custom attribute on the configurable page when I click to the swatch color attribute. On this purpose I programmatically created custom attributes with options on the admin panel, where I can save for every product his own custom attributes.
I figure out how to call my custom attributes on simple products but I can't to do this with configurable product.
I see when I change color attribute - price is changed for every simple product([it's default thing), how to do same but with my custom attributes?
I have one idea but I don't know how this one implement. So I know how to get current product id when you clicked on the color attribute(through js code) then I need pass this id data to the controller via ajax. I need to know how exactly to do this, how to pass js data through ajax to controller and then call needed block on the category page every time when I click on the color attribute? ? When I will be know how to do that I get with this id data - custom attribute values and call this template in the needed place.
Code below is that what call custom attributes on the configurable product, but it's call all attributes for all simple products included in the configurable product. I need call these attributes for current product every time when I cliked on the color attribute. For example: if I click on the black color (which related to the product with id 123 ) I get custom block with custom attributes without reloading page(like price).color attributes
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->get('Magento\Framework\Registry')->registry('current_product');
$product_id = $product->getId();
$configProduct = $objectManager-
>create('Magento\Catalog\Model\Product')->load($product_id);
$configurable = $configProduct->getTypeId() ==
\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE;
$_children = $configProduct->getTypeInstance()-
>getUsedProducts($configProduct);
if ($configurable){
foreach ($_children as $child){
$child_badge = $child->getResource()->getAttribute('mycustom_attribute_code')->getFrontend()->getValue($child);
echo $child_badge;
}
}

Dont remove filters in magento

I Apply filter in magneto. But if I Click on any filter some filter are hide now I want to show all filter always.Any help will be appreciated.
the part of code that hides other options located at app\code\core\Mage\Catalog\Model\Layer\Filter\Attribute.php this part.
if ($filter && strlen($text)) {
$this->_getResource()->applyFilterToCollection($this, $filter);
$this->getLayer()->getState()->addFilter($this->_createItem($text, $filter));
$this->_items = array();
}
Overwrite this part in local pool.

when I use If isset($_FILES['something'] I can't access my controller array in my view in codeigniter?

when I load same view in If Else condition I cant access my view as data in view control !! For Example (This code is for Edit Profile pic)
if(isset($_FILES['file1']))
{
//here some code to upload photo and resize it
$data2['avtar'] = $this->upload_model->update_photo($source) //Retriving data from model
$this->load->view('profile_view',$data2,TRUE);
}
else
{
$this->load->view('profile_view');
}
I can't access $data2['avtar'] value in my view !! when I remove third parameter true I can see its value in view using var_dump($avtar) but it loads two view of same page and mixed in one another. I want to access only image path to view whom I can put in <img src=""> in my view. so tell me whats the problem?
From the Docs
If you set the parameter to true (boolean) it will return data. The
default behavior is false, which sends it to your browser. Remember to
assign it to a variable if you want the data returned:
$string = $this->load->view('myfile', '', true);
By examining the provided code, I can not see how it loads two view of same page. Maybe your code is in a loop.
You can also use AJAX to update the image.

Big Cartel cart

I have made a custom theme on big cartel, and everything is perfect, except one thing.
I would like to have the cart update without going to the cart page when adding an item to your cart.
I have made my custom template over the "sexy" theme and have no idea how I go about implanting this
I know this can be done, because default themes like "Good Vibes" do this.
You can use the code below. I didn't include the code for the restoreButton function in the addItem callback but I'm sure you get the idea. You'll also need your own means of retrieving the product ID based on however you're displaying your product options. Make sure to also include a reference to Big Cartel's javascript api.
$('#add_to_bag').click(function(evt){
var productId;
if($('.options_select').length != 0)
productId = $( ".options_select option:selected" ).attr('value');
else
productId = $('.price_options input').attr('value');
var quantity = $('.quantity input').attr('value');
Cart.addItem(productId, quantity, function(cart) {
$('#add_to_bag').attr('value', 'Item Added');
setTimeout(restoreButton, 2000);
});
});
You'll want to take advantage of the javascript API: https://help.bigcartel.com/developers/themes/#javascript-api
With this, you can drop in the line of code to load the API into your theme and have access to add, update, and remove items from the cart using javascript.

Hide a group in catalog product?

Please help me if anybody know how this work can be done.
I want to hide the website tab in catalog Product, but its functionality should exist. That is, I have made all the check boxes automatically checked,so i dont want to show this tab anybody...but at the time of adding product..check boxes values would be saved.
Not exactly sure how you would do this, but basically you need to bind an Observer in the adminhtml render sequence that calls Mage_Adminhtml_Block_Widget_Tabs::removeTab($tabId) where $tabId is the Id of the websites tab (I think it's just "websites"). The trick is to find the right event to bind your Observer to, #Joseph's list of events should get you started. I would try something like adminhtml_block_html_before.
Your observer would also set the values on the product at the same time.
Good luck,
JD
In ProductController.php
Websites
*/
if (!isset($productData['website_ids'])) {
$productData['website_ids'] = array();
}
$productData['website_ids']=$this->getStoreWebsiteId(); //newly added
//newly added
public function getStoreWebsiteId(){
$selectWebsite="SELECT * from core_website WHERE website_id!=0";
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$value=$connection->fetchAll($selectWebsite);
foreach($value as $websiteDetails){
$websiteId[]=$websiteDetails['website_id'];
}
return $websiteId;
}

Resources