Support Home / Magento Support / Extending the MadeToOrder Plugin to enable additional mto_* attribs...

Page of 0 | Showing 6 records | Total records found: 0
Author Post
derekdon
posted on : Feb 26, 2010 - 11:04 AM

Hey Mark,

Been gone awhile! A big thanks for MTO 1.0. Quick house keeping question. I need two additional mto attributes attached to each mto product orderItem/quoteItem. These attributes will be type of text and their values will be set internally by the system during the ordering process so I don't need any frontend fields. For example the attributes might be mto_user_commands and mto_admin_commands, type of text, and have a value of a user/admin specific JSON code.

My question is, should I create a separate module to add these on should I modify your code to do this? I think a separate module would be good as your version works as is, and this is just a slight addition required for my specific project.

Also I just wanted to ask about your attribute declaration in your SQL setup files, and why some of the attributes you define appear in the Manage Attributes and some don't. It's probably a silly question and is based on attribute type, but take this for example...

line_item_details (Hidden in Manage Attributes) vs mto_height_step (Shown in Manage Attributes)

I need to be able to set the values of my two additional mto attributes per orderItem/quoteItem, but the fields/values don't need to be visible outside of the database, ie. Magento Admin, Product Page, Checkout etc.

I hope this all makes sense.

Derek.

 

Mark Kimsal
posted on : Feb 26, 2010 - 07:09 PM

Great question Derek.

The line_item_details is hidden from the magento attributes because it is a carrier for dynamic information, wherease mto_height_step is not. Things are dynamically set on the line_item_details as the user adds products to their cart. With the mto_height_step, you need to set a value for each product so that the product information page knows how to render the measurement fraction (i.e. every 1/4 inch). Setting the line_item_details for each product doesn't make sense. The line item detail is just a carrier of information for order items. I don't think I set them to be available for product types (see the entity_type_id).

If you need to set more information for order items/quote items you can follow the line_item_details example. Actually, most of the time I embed any information into the line item details and use substr() parsing and explode("\n") to get the information back out when needed.

 

Mark Kimsal
posted on : Feb 26, 2010 - 07:11 PM

I would probably not create a new module. Just do all of your additional coding inside Helper classes and name them uniquely. You can shove extra installation variables into the existing SQL files, but that might be your only pain point if you upgrade to another version of MTO. If you use your own git or svn repo, you should have no worries about losing your SQL. Just pull out a previous version and merge the changes by hand.

 

derekdon
posted on : Mar 9, 2010 - 05:19 PM

Hi Mark,

Sorry for the delay in responding...

Thanks for clearing that up and for the additional suggestions. I've actually created a separate module as I found that in my case there is separation between what I need and your MTO module. They can work independently of each other and together, but one doesn't rely on the other. This means I won't have to worry about SQL upgrade problems thankfully. I used the info you provided about hidden and visible attributes to set this up as needed, thanks.

I also wanted to pick your brain if you don't mind about the MTO add-on price calculation. By default when you check the add-ons you what on the product page the price doesn't update via ajax, but in the cart the new price is calculated from your selections. I wanted to change this behaviour so that the price updates on the product page, so I moved the frontend add-ons html code into customize.phtml before the js, and added class="mto-attribute" to the echo'd add-on checkbox inputs. Now when checked and unchecked on the product page, the price updates, but incorrectly! It always doubles on any add-on selection, and doesn't revert on an unselection...

I've added additional output to the getDynPriceAction method of the controller...

Code:
public function getDynPriceAction() {
        $this->_initProduct();
        $qty  = (string) $this->getRequest()->getParam('qty');
		//make this I18n: some countries enter "1.000.000,99"
        $qty = Zend_Locale_Format::getNumber($qty, array('locale' => Mage::app()->getLocale()->getLocaleCode(), 'precision'=>4));
		try {
	        $price = Mage::registry('current_product')->getTierPrice($qty);
		} catch (Exception $e) {
			echo "Error with pricing.";
			return;
		}
		//don't include the container with formatPrice
        echo 'qty:' . $qty . ',  price:' . $price . ' - ' . Mage::app()->getStore()->formatPrice($price);
    }


qty always seems to be correct but the price is always wrong... I think it may just be getting calculated differently here then in the cart. If I add the $15 product to the cart with one $6 add-on selected with a qty of 4, in the cart the unit price is double what it should be plus the add-on price, so it's $36. The qty is correct at 4, and the subtotal is correct for the values in the cart, at $144. This only happens when I'd ajax enabled the add-on selection to update the price.

My guess is that, MTO's Product Model > getDynamicPrice method is having problems with this, possibly because of the pricing sheets... I'm not sure.

My test product's pricing sheet looks like this...

Code:
<mto_pricingrules>
	<productLine>
		<product>
			<condition type="range" attrib="sqft" value="0-44999">15.00</condition>
			<condition type="range" attrib="sqft" value="45000-79999">30.00</condition>
			<condition type="range" attrib="sqft" value="80000-149999">45.00</condition>
			<condition type="range" attrib="sqft" value="150000-179999">50.00</condition>
			<condition type="range" attrib="sqft" value="180000-200000">65.00</condition>
		</product>
	</productLine>
</mto_pricingrules>


Any ideas on what's going on or different between the cart and here?

Many thanks,

Derek.




 

derekdon
posted on : Mar 23, 2010 - 07:06 PM

Mark,

Okay I've made a number of updates to the code base and added a couple of things, one being a show/hide spinner method to the ajax code to show when the price is updating.

The problem with the addons doubling the price on the Product View page (remember I added the mto-attribute class to the addon checkboxes) has been sorted and was related to a problem in my pricing sheet. I can select/deselect without a problem and the price update will trigger but obviously as the addon price values aren't processed until the checkout the price remains static.

The qty stuff makes sense to me now in relation to the pricing sheets and Product View updates. I kind of expected to see the price in the Product View updating to a multiple of the quantity value, buy obviously that doesn't make any sense. I might a "Unit Price" caption beside the actual price in my design...

My test pricing sheet now looks like this and works as expected.

Code:
<mto_pricingrules>
	<productLine>
		<product>
			<condition type="range" attrib="qty" value="0-5">
				<condition type="range" attrib="depth" value="0-14">
					<condition type="range" attrib="sqft" value="0-61250">20.00</condition>
					<condition type="range" attrib="sqft" value="61251-101250">40.00</condition>
					<condition type="range" attrib="sqft" value="101251-151250">50.00</condition>
					<condition type="range" attrib="sqft" value="151251-151250000000000">60.00</condition>
				</condition>
				<condition type="range" attrib="depth" value="15-19">
					<condition type="range" attrib="sqft" value="0-61250">25.00</condition>
					<condition type="range" attrib="sqft" value="61251-101250">45.00</condition>
					<condition type="range" attrib="sqft" value="101251-151250">55.00</condition>
					<condition type="range" attrib="sqft" value="151251-151250000000000">65.00</condition>
				</condition>
				<condition type="range" attrib="depth" value="20-24">
					<condition type="range" attrib="sqft" value="0-61250">30.00</condition>
					<condition type="range" attrib="sqft" value="61251-101250">50.00</condition>
					<condition type="range" attrib="sqft" value="101251-151250">60.00</condition>
					<condition type="range" attrib="sqft" value="151251-151250000000000">70.00</condition>
				</condition>
				<condition type="range" attrib="depth" value="25-30">
					<condition type="range" attrib="sqft" value="0-61250">35.00</condition>
					<condition type="range" attrib="sqft" value="61251-101250">55.00</condition>
					<condition type="range" attrib="sqft" value="101251-151250">65.00</condition>
					<condition type="range" attrib="sqft" value="151251-151250000000000">75.00</condition>
				</condition>
			</condition>
			<condition type="eqgt" attrib="qty" value="6">
				<condition type="range" attrib="depth" value="0-14">
					<condition type="range" attrib="sqft" value="0-61250">10.00</condition>
					<condition type="range" attrib="sqft" value="61251-101250">20.00</condition>
					<condition type="range" attrib="sqft" value="101251-151250">25.00</condition>
					<condition type="range" attrib="sqft" value="151251-151250000000000">30.00</condition>
				</condition>
				<condition type="range" attrib="depth" value="15-19">
					<condition type="range" attrib="sqft" value="0-61250">12.50</condition>
					<condition type="range" attrib="sqft" value="61251-101250">22.50</condition>
					<condition type="range" attrib="sqft" value="101251-151250">27.50</condition>
					<condition type="range" attrib="sqft" value="151251-151250000000000">32.50</condition>
				</condition>
				<condition type="range" attrib="depth" value="20-24">
					<condition type="range" attrib="sqft" value="0-61250">15.00</condition>
					<condition type="range" attrib="sqft" value="61251-101250">25.00</condition>
					<condition type="range" attrib="sqft" value="101251-151250">30.00</condition>
					<condition type="range" attrib="sqft" value="151251-151250000000000">35.00</condition>
				</condition>
				<condition type="range" attrib="depth" value="25-30">
					<condition type="range" attrib="sqft" value="0-61250">17.50</condition>
					<condition type="range" attrib="sqft" value="61251-101250">27.50</condition>
					<condition type="range" attrib="sqft" value="101251-151250">32.50</condition>
					<condition type="range" attrib="sqft" value="151251-151250000000000">37.50</condition>
				</condition>
			</condition>
		</product>
	</productLine>
</mto_pricingrules>


Everything else seems to be going fine. I still would like to have the price update from the addons in the Product View so I will inspect the code you have for this in the cart and see if I can do something after the price sheet calculation so that it doesn't interfere with it. Think it would look better if all the mto options (besides qty) updated the price in the Product View.

Talk soon,

Derek.

 

derekdon
posted on : Mar 25, 2010 - 03:27 PM

Hi Mark,

Just to give you a heads up, I managed to get the addon selections to update the price on the Product View page via a small code addition to the MtoController that adds the combined addon value to the price before it returned. Easy enough, just hadn't looked at it properly.

Now the last thing I think I need to do it to is re-apply the users MTO selections to the fields in the Product View page when they click on the product again from the cart page, as currently when this happens all their selections aren't re-applied. May they are meant to but they aren't for me. Perhaps the details are in the request, I probably need to pull them out manually and re-apply them.

Thanks,

Derek.