Magento - Покажите Пользовательские атрибуты в Сгруппированной Таблице product

Пространство имен System.Reactive.Linq содержит статический класс Observable, который определяет все методы расширения для общих реактивных комбинаторов. Он содержится в System.Reactive.dll

Методы расширения для IObservable<T>.Subscribe, такие как Subscribe(onNext), Subscribe(onNext, onError), определены в mscorlib в статическом классе System.ObservableExtensions.

tl; dr:

  • Для методов расширения Rx / Observable вам необходимо импортировать System.Reactive.Linq = using System.Reactive.Linq;
  • Для перегрузок подписки необходимо импортировать System = using System;
5
задан Glorfindel 23 March 2019 в 05:59
поделиться

2 ответа

All Magento models have a "getData" method available, which will return an php-array of key/value pairs. Try this at the top of your grouped.phtml file (after $_product is defined)

print('<pre>');print_r($_product->getData());print('</pre>');

You should see output that looks something like the following.

Array
(
    [store_id] => 1
    [entity_id] => 3437
    [entity_type_id] => 4
    [attribute_set_id] => 27
    [type_id] => grouped
    [sku] => 
    [category_ids] => 
    [created_at] => 2009-04-16 03:37:51
...     

So, you can grab an array of properties and just pull the key out. You could also use Magento's convenience/magic getX and setX methods. On all Magento models, you can access any property in the data array by calling a method based on the camel case version of the name,

$created_at = $_product->getCreatedAt();
$_product->setCreatedAt($date);

So, whatever your custom attribute name is, you should be able to get at it using the above, and if you're not sure just print_r or var_dump the contents of the array returned by getData().

Finally, if the custom attribute is on one of the related products simple product, you'll wants something more like

$_associatedProducts[0]->getCreatedAt();
3
ответ дан 15 December 2019 в 06:33
поделиться

Из вер. 1.3. и в 1.4 вы также должны использовать $ _ item , а не $ _ product , для меня это тоже отлично работает в группируемой таблице.

Пример:

<?php echo $_item->getAttributeText('your attribute'); ?>
0
ответ дан 15 December 2019 в 06:33
поделиться
Другие вопросы по тегам:

Похожие вопросы: