2013-12-23

Magento: получение всех атрибутов продуктов

public function getAttributes()
{
 $result = [];

 $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
  ->getItems();

 foreach ($attributes as $attribute){

  $result[] = [
   'label' => $attribute->getAttributecode(),
   'value' => $attribute->getFrontendLabel()
  ];
 }

 return $result;
}

Или:
public function getAttributes()
{
 $attributes = Mage::getModel('catalog/product')->getAttributes();
 $attributeArray = [];

 foreach($attributes as $a){

  foreach ($a->getEntityType()->getAttributeCodes() as $attributeName) {

   $attributeArray[] = [
    'label' => $attributeName,
    'value' => $attributeName
   ];
  }
  break;
 }
 return $attributeArray;
}

2013-12-09

Получение CMS страницы

Получение CMS страницы:
$block = Mage::getModel('cms/page')->setStoreId(Mage::app()->getStore()->getId())->load($id);
$html = $block->getContent();

2013-11-27

Изменение группы атрибутов для товара

Группа атрибутов указывается через id, его можно посмотреть в таблице eav_attribute_set.
foreach ($products as $_product) {
 if ((int)$_product->getData("attribute_set_id") !== 64) {
  $_product->setData("attribute_set_id", 64);
  $_product->save();
 }
}

Magento: get tier price

Для получения tier price:
$product->getTierPrice();

Возвращает массив:
Array
(
    [1-1] => Array
        (
            [price_id] => 6
            [website_id] => 7
            [all_groups] => 0
            [cust_group] => 1
            [price] => 30.0000
            [price_qty] => 1.0000
            [website_price] => 30.0000
        )

)

2013-11-26

Response status codes

Server response status codes:
• 1xx: Informational - Request received, continuing process
• 2xx: Success - The action was successfully received, understood, and accepted
• 3xx: Redirection - Further action must be taken in order to complete the request
• 4xx: Client Error - The request contains bad syntax or cannot be fulfilled
• 5xx: Server Error - The server failed to fulfill an apparently valid request

2013-11-14

Передача параметров в дочерний template

Передать параметр в template можно так:
$this->getChild('quickgalleryview')->setData("productId", $_product->getId());
echo $this->getChildHtml('quickgalleryview');

Или если template вызывается несколько раз:
echo $this->getChildHtml("quickgalleryview", false)

Использовать переданный параметр так:
$this->getData("productId")

2013-11-13

Включение WYSIWYG редактора

Для добавления WYSIWYG редактора добавляем кнопку
<button
  onclick="catalogWysiwygEditor.open('/admin/catalog_category/wysiwyg/key/<?php echo $this->getFormKey(); ?>', 'id_<?php echo $this->getHtmlId() ?>')"
  class="scalable btn-wysiwyg"
  type="button"
  title="WYSIWYG Editor">
  <span><span><span><?= Mage::helper('core')->__('WYSIWYG Editor') ?></span></span></span></button>

При нажатии на нее будет открываться редактор и редактировать текстовое поле с переданным id