Hide a group in catalog product? - events

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;
}

Related

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 text from one magento store

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.

How to get the attributes selected Magento

what I need is relatively simple ...
I need to get the attributes that have been selected in the product page.
Explaining better:
I have a configurable product and have two attribute, size and color. When I go to buy the product, I have the options to select the attributes, I have a button that will do some actions and need to get the attributes that are selected.
On change of the dropdown do a ajax call which would return from the selected value
This would get you all attribute option and value. Change it according to your requirement
$attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'color');
if ($attribute->usesSource()) {
$options = $attribute->getSource()->getAllOptions(false);
}
Still not sure what you want to achieve

Magento event name to observe

I need to add some code to Magento (1.6.2) to be executed when an orders status becomes Complete.
In our system, this happens when the order is "Shipped" - i.e. the "Ship" button is clicked, and the shipping info is saved.
I have hunted (obviously in the wrong places) to try and find what that event would be called, so that I can add an observer to watch for it firing, and then run my code.
Can anyone tell me what the name of this event would be (if it exists as an observable event) please?
Cheers!
I too find event hunting to be a bit of a dark art. In this case I would try sales_order_save_before and then check in a handler like this:
function onSalesOrderSaveBefore(Varien_Event_Observer $observer)
{
$order = $observer->getOrder();
if (($order->getData('status') == 'complete')
&& ($order->getOrigData('status') != 'complete')) {
// then order has just been completed
}
}
One possible solution is to create a custom module that override this controller
/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php
Then add your custom code or create you own custom event in public function saveAction()

MVC3 - display price based on product selection in form

I am sure there will be articles around this but I really don't know the correct name for it and having little success finding examples like mine.
I have a quote form where you have the ability to select a product and atributes of it. There are three dropdowns and based on the combination of the three, I have a table (with associated model/controller) that has a price. I want to display the price on the page but i must update as the selections are updated.
Setting the price from the get go seemed easy but then updating it based on dropdowns selected had me go in a tail spin of '"onSelectedIndexChanged()', javascript, AJAX, partial views and I simply confused myself.
I need a simple way to display price information on a quote form as they fill out the details (three fields control price). I did look at the music store demo but its slightly different and the shopping cart element which looked handy was grabbing data in a table so again got stuck.
Help always appreciated as ever.
Thanks,
Steve.
When one of the three dropdowns changes, I'd make an AJAX call to the server to get the price as a JSON object and use it to update the price input.
Example using jQuery to add the handlers and perform the AJAX operation.
var $priceControls = $('#control1,#control2,#control2');
$priceControls.change( function() {
$.getJSON( '#Url.Action("price","product")',
$priceControls.serialize(),
function(price) {
$('#price').val(price);
});
});
public class ProductController : Controller
{
public ActionResult Price( string control1, string control2, string control3 )
{
decimal price = ...lookup price based on control values...
return Json( price, JsonRequestBehavior.AllowGet );
}
}

Resources