Привет для веб-сайта Magento мне нужно загрузить пользовательский атрибут в корзину покупок.Загрузите пользовательский атрибут в корзину Magento
Я использую функцию getmodel для загрузки элементов. но я не знаю, как загрузить атрибут. возможно, я не правильно настроил атрибут. Я включил да для включения в список продуктов. Код атрибута - «staffel_percentage». это просто обычная строка
также, когда я меняю цену за продукт, это не меняет промежуточный итог, может быть, это потому, что мы уже изменили цену продукта на остальной части сайта?
Возможно, это событие? Я использую это событие: controller_action_layout_render_before.
это код в наблюдателя я использую для него
$cart = Mage::getModel('checkout/cart')->getQuote(); // Gets the collection of checkout
foreach ($cart->getAllItems() as $item) { // adds all items to $item and does the following code for each item
if ($item->getParentItem()) { // If items is part of a parent
$item = $item->getParentItem(); // Get parentItem;
}
//echo 'ID: '.$item->getProductId().'<br />';
$percentage = 80;// init first percentage
$quantity = $item->getQty(); //quantity
//$staffelstring = loadattribute//loads attribute
//gives the right percentage per quantity
//$staffelarray = explode(';', ^);
//foreach($staffelarray as $staffels){
//$stafel = explode(':', $staffels);
//if($quantity >= $stafel[0]){
//$percentage = $Stafel[1];
//}
//}
$currency = Mage::app()->getStore()->getCurrentCurrencyRate(); // Currencyrate that is used currently
$specialPrice = (($this->CalculatePrice($item) * $currency)* $percentage)/100; //New prices we want to give the products
if ($specialPrice > 0) { // Check if price isnt lower then 0
$item->setCustomPrice($specialPrice); //Custom Price will have our new price
$item->setOriginalCustomPrice($specialPrice); //Original Custom price will have our new price, if there was a custom price before
$item->getProduct()->setIsSuperMode(true); //set custom prices against the quote item
}
}