Skip to content

Instantly share code, notes, and snippets.

@ceckoslab
ceckoslab / order ids helper
Created July 28, 2014 15:32
Example snippet of helper class, that checks if the order items are owned by the current customer
<?php
/**
* @author Tsvetan Stoychev <tsvetan.stoychev@jarlssen.de>
* @website http://www.jarlssen.de
*/
class MyCompany_MyModule_Helper_Data extends Mage_Core_Helper_Abstract
{
/** @var Varien_Db_Adapter_Interface $readConnection */
@ceckoslab
ceckoslab / example sql query
Created July 28, 2014 15:25
Check if order items are owned by the current customer
SELECT `oi`.`item_id`, `o`.`customer_id` FROM `sales_flat_order_item` AS `oi`
RIGHT JOIN `sales_flat_order` AS `o` ON oi.order_id = o.entity_id and o.customer_id != 8 WHERE (oi.item_id IN(2, 3))
/**
* In case we got validation error we have to specify an error
* message, that will be shown in the quote
* (usually shown in the cart heading section or product heading section
*
* @return string
*/
public function getQuoteMessage()
{
return "Not allowed product quantity in the cart";
/**
* In case we got validation error we have to specify and error
* message, that will be show in the quote item line
*
* @return string
*/
public function getQuoteItemMessage()
{
return "The quantity must be multiple times of 10";
}
/**
* Implementation of the validation logic
*
* @param Mage_Sales_Model_Quote_Item $item
* @return bool
*/
public function validate($item)
{
$qty = $item->getQty();
<global>
<jarlssen_custom_cart_validation>
<rules>
<different_manufacturer_not_allowed>
<product_type>simple</product_type>
<model>example_validation/validator_validateAllowedManufacturers</model>
<origin>example_validation</origin>
<code>1</code>
</different_manufacturer_not_allowed>
@ceckoslab
ceckoslab / Jarlssen_CustomCartValidation - dependency.xml
Created May 13, 2014 18:03
Jarlssen_CustomCartValidation - dependency
<?xml version="1.0"?>
<config>
<modules>
<MyCompany_ExampleValidation>
<active>true</active>
<codePool>local</codePool>
<depends>
<Jarlssen_CustomCartValidation />
</depends>
</MyCompany_ExampleValidation>
@ceckoslab
ceckoslab / Real-option-example
Last active August 29, 2015 14:01
Jarlssen_FasterAttributeOptionEdit - Real option
<td>
<input value="William Shakespeare" name="option[value][116][0]" class="replace-content pseudo-input input-text required-option">
</td>
@ceckoslab
ceckoslab / Placeholder-markup-example
Created May 7, 2014 08:44
Jarlssen_FasterAttributeOptionEdit - Placeholder markup
<td>
<div id="option[value][116][0]" class="replace-content pseudo-input input-text required-option">Option 2</div>
</td>
@ceckoslab
ceckoslab / custom chooser example.php
Last active August 29, 2015 14:00
Jarlssen_ChooserWidget - custom chooser example
$chooserHelper = Mage::helper('jarlssen_chooser_widget/chooser');
$customChooserConfig = array(
'input_name' => 'entity_link',
'input_label' => $this->__('Custom entity'),
'button_text' => $this->__('Select entity…'),
'required' => true
);
$chooserBlock = 'custom_module/chooser';