I'm starting to build a new Magento site and its primarily focused on clothing brands. Launching with around 25 each one providing a range of products in categories. so some will have everything from shoes to jumpers, some may just be shoes or accessories.
Users need to be able to view a brand and see its categories for products, as well as via a different view view all of a type of product category so all shoes.
I really don't know how to set this kind of thing up. I know i could use categories for the brands then sub categories for the clothing categories, but then i don't know how linking sub categories items together would work (I've viewing all jumpers across all brands if they have separate parent categories).
Here'show the structure needs to work
Brand_1{
Shoes{
Item 1,
Item 2
}
Coats{
Item 3
}
},
Brand 2{
Shoes{
Item 4,
Item 5,
Item 6
}
Jumpers{
Item 7,
Item 8,
Item 9
}
Accessories{
Item 10
}
Shirts{
Item 11
}
},
Brand 3{
Shoes{
Item 12,
Item 13,
Item 14
}
}
So users can view brand 1 page, see items 1-3. Or view brand 1>Shoes and see items 1-2. Or view Shoes and see items 1,2,4,5,6,12,13,14.
The way I chose to work this out was to create a custom attribute as a brand drop down to assign a brand to every item. Then I chose to create a custom admin module with a database table to store the brand details giving the ability to store extra information for each brand, that feeds into the attribute dropdown.
Related
Show only : "Clip with Shining Red"
If the product is out of stock, add to cart button will be replaced by the first 4 words of the product's title. I have the code for this but it shows the whole product's title
Here's the code
When product.title returns the full title then
product.title.split.take(4).join(' ')
would return the first four words of that title.
I work as an operations manager at at small business and I'm trying to set up an order sheet that is easy for the salesman to use. In the order sheet, I've used the OFFSET function to refer to a master list containing customers and prices. Under Customer, I type the customer and it draws it from the master list via an auto-complete drop-down. The same happens with the product.
Here is the order sheet:
Order Sheet Example
My issue is I'll begin typing in the product e.g. 'prawn'. We have over a dozen prawn lines, but a particular customer will only take one. All of the other prawn results have no prices for that customer. However, the auto-complete function will offer up all the 'prawn' results.
In the Master list, I've entered prices for only the products that the particular customer uses. Take a look at what the Master List looks like:
Master List look
Without an excellent memory of what customer wants what, it's an exercise in trial and error. In the above example, I could type 'topside' and if I select the wrong one, no price comes up.
This is frustrating.
I was hoping for a way to limit the auto-complete so that when I type 'prawn' or 'topside' for that customer, it only comes up with auto-complete fields that have the price in it. Can anyone help? Or does anyone know of any work-arounds? I'd be really thankful, the current order system is quite difficult.
I believe this will do what you want. It is a little difficult to tell from your sample data. It uses google apps script and sheet names and/or columms may need to be changed in the script for your data. I am attaching a sample spreadsheet you can copy then try. You will have to approve the script in the copy you make.
function onEdit(e) {
var cust=e.value //The value of the edited cell
var sh=e.source.getActiveSheet().getSheetName()//Name of the active sheet.
var col=e.range.getColumn()//The edited column
var r=e.range.getRow()//The edited row
var row=e.range.offset(0,1).getA1Notation()//Cell A1 notation of cell in same row one column to the right.
var ss=SpreadsheetApp.getActiveSpreadsheet()
var s=ss.getActiveSheet().getSheetName()//Name of active sheet
var s1=ss.getSheetByName("Sheet1")//Variables for sheets
var s2=ss.getSheetByName("Sheet2")
var s3=ss.getSheetByName("TEMP")
var rng=s2.getDataRange().getValues()//Customer/Products
if(sh=="Sheet1" && col==1){//If sheet1 is active sheet and Customer (column A) is edited.
var array=[]//Array to hold customers products
for (var i=0;i<rng.length;i++){
if(rng[i][0]==cust ){
for(var j=1;j<rng[0].length-1;j++){
if(rng[i][j]!="" ){//If customers product has $ entry add to Array.
array.push([rng[0][j]])
}}}}
s3.clearContents()//Clear old product list from TEMP.
s1.getRange(row).clearContent()//Clear product dropdown
s3.getRange(1,1,array.length,1).setValues(array)//Set new customer product list in TEMP.
drop(row,cust)// Call drop function to build new dropdown.
}
if(sh=="Sheet1" && col==2){//If sheet1 is active sheet and Product (column B) is edited.
var cust1=e.range.offset(0,-1).getValue()//Get customer in A
var prod=e.range.getValue()//Get selected product
for (var i=0;i<rng.length;i++){//Get the customer/product price
if(rng[i][0]==cust1 ){
for(var j=1;j<rng[0].length-1;j++){
if(rng[0][j]==prod){
price=rng[i][j]
s1.getRange(r,5).setValue(price)//Set the price in column E
s1.getRange(r,2).clearDataValidations() //Remove the data validation dropdown in column B
}
}}
}}}
function drop(row,cust){
var ss=SpreadsheetApp.getActiveSpreadsheet()
var s3=ss.getSheetByName("TEMP")
var s1=ss.getSheetByName("Sheet1")
var cell = s1.getRange(row);//set validation in B
var ocell=s1.getRange(row).offset(0, -1).getValue()//evaluate value in A
var cellVal=cell.getValue()
if(ocell==cust){
var lr= ss.getSheetByName("TEMP").getLastRow()
var range = ss.getSheetByName("TEMP").getRange(1, 1, lr, 1)
var rule = SpreadsheetApp.newDataValidation().requireValueInRange(range).build();//Build the dropdown
cell.setDataValidation(rule)}//Set the validation rules (Customers
products)
}
Test spreadsheet:
https://docs.google.com/spreadsheets/d/1u86sdf1_mO-Mv7hQM_hRZl3Gma-Y2lsu9ZvxSW4jA1U/edit?usp=sharing
In Eclipse E4 (Luna), using the application model to create parts, handlers, commands, handled menu items etc, (these are not created programatically). I have a toolbar. This contains a sub-Menu item called "Filter" that contains another sub-menu of two filters. The two filters are two Handled Menu Items which are set up as "Radio" Buttons.
When I select the appropriate in the UI of my running app from the selection, the Radio button switches just fine to the selected Item. However I would like this selection to update (deselecting one Radio button and selecting the appropriate radio button of the handled menu item) when my ViewPart changes through other UI selection. Currently my ViewPart updates, but the Radio buttons are on the same previous selection through the UI.
Is there a way in which I get access both Handled Menu Item's IDs and set the selection (one to false, the other to true) when the viewer is updated.
Image of design is attached below:
Hierarchy of the application model is as follows:
Thanks in advance,
Marv
You can use the model service to find menu items. Use something like:
#Inject
EModelService modelService;
#Inject
MApplication app;
List<MMenuItem> items = modelService.findElements(app, "menu item id", MMenuItem.class, Collections.emptyList(), EModelService.IN_MAIN_MENU);
Once you have the MMenuItem you can call the setSelected(boolean) method to change the selection.
To find a menu item which is in a Part menu use:
modelService.findElements(app, "menu item id", MMenuItem.class, Collections.emptyList(), EModelService.IN_PART);
(IN_PART argument instead of IN_MAIN_MENU).
You could also specify the MPart rather than the Application as the first argument to findElements which may speed up the search.
For menus as a child of a Tool Bar Item it appears that the model services cannot find these directly. However you can find the Tool Bar Item and look at the menu yourself:
List<MToolItem> items = modelService.findElements(app, "tool bar item id", MToolItem.class, Collections.emptyList(), EModelService.IN_PART);
MToolItem item = items.get(0);
MMenu menu = item.getMenu();
List<MMenuElement> children = menu.getChildren();
... search menu elements
I solved this by starting with MPart PartID and drilling down to the HandledMenuItems on which I wanted to set the Radio Button selections, then setting the selection property for each individual HandledMenuItem.
This can probably be refactored to be more concise, but I've left the code with each step to have the solution easier to read.
BTW, in every instance / combination of the EModelService methods, the list returned a size of 0. So I'm not certain if that will work for what I'm trying to achieve. The following does work, although I'm not certain it is the most efficient means.
I hope this helps others.
// Get view part
MPart viewPart = _partService.findPart("part_id");
// get list of all menu items from the Part
List<MMenu> viewPartMenu = viewPart.getMenus();
// Get list of ViewMenus from viewPartMenu there is only one View Menu so it will be index 0
MMenu viewMenu = viewPartMenu .get(0);
// Get list of MMenuElements from the viewMenu - the children in the view menu
List<MMenuElement> viewMenuElements = viewMenu.getChildren();
// This gets me to the 2 HandledMenuItems
// Upper Most HandledMenuItem Radio Button is at viewMenuElements index 0. This is cast to MHandledMenuItem
MHandledMenuItem upperHandledMenuItem = (MHandledMenuItem) viewMenuElements.get(0);
// Set Selection
upperHandledMenuItem.setSelected(false);
// Lower Most HandledMenuItem Radio Button is at viewMenuElements index 1. This is cast to MHandledMenuItem
MHandledMenuItem lowerHandledMenuItem = (MHandledMenuItem) viewMenuElements.get(1);
// Set selection
lowerHandledMenuItem.setSelected(true);
I am trying to display the cross sell product on a magento product oagei get the cross sell products like this
$_crossSellProducts = $_product->getCrossSellProducts();
if($_crossSellProducts):
foreach ($_crossSellProducts as $_item):
$_item = Mage::getModel('catalog/product')->load($_item->getId());
I need to be able to sort the cross sell items by position. How can i do this?
knowzero,you cant sort crossell products by position because of position depends on category.product of same category may sort by postion
I am looking to make a product that offers several sizes and colors, and allow the customer to select different sizes and colors (and quantities of each) on one page and submit to add several variations at once to the cart
example: Customer wants to order
10 Small Black shirts
10 Medium Black shirts
20 Large Black shirts
5 Small White shirts
5 Medium White shirts
10 Large Black shirts
they input the numbers in a grid view on the "Product View" page and click submit once, adding 60 products to their cart at once
I have looked for add-on and mods that are already created for either purchase or free and could not find any.
I coded a theme like this. The way I did it was to use simple products. Build a page, as you suggest, that has an HTML form for the user to indicate which product_id and what quantities and then have that form submit a JSON POST of {product_id:qty} pairs to a custom controller that can then recover product_id=>qty pairs from the POST and then loop over $cart->addProduct($product,$request); for each object in the POST.
So in your custom controller, you can get an array of $product_id=>$qty from something like
$lolo_skusToAdd = $this->getRequest()->getParam('skuJson',false);
$testArray = json_decode($lolo_skusToAdd, true);
//...
foreach($testArray as $sku=>$qty){
//Mage_Checkout_Model_Cart->addProduct() wants quantity as a Varien Object
$request = new Varien_Object(array('qty' => $qty));
//...
$eventArgs = array(
'product' => $product,
'qty' => $qty,
'additional_ids' => array(),
'request' => $this->getRequest(),
'response' => $this->getResponse(),
);
Mage::dispatchEvent('checkout_cart_before_add', $eventArgs);
try{
$cart->addProduct($product,$request);
Mage::dispatchEvent('checkout_cart_after_add', $eventArgs);
//...
I've left a lot of code out. My controller is a bit messy and actually specialised for a custom situation: it uses ajax to receive the POST and return either success messages or failure messages.
I hope this has given you some pointers in the right direction. If you go this way you should read the normal add to cart controllers to see how 'default Magento' adds products to the cart and mimic that in your custom controller so you can include all the Mage::dispatchEvents() and the $cart->save() and the session message updates etc etc