magento 1.9 – attribute not loading in Cart

I am trying to use custom code to show shipping estimates based on the product SKU or Manufacturer.

the SKU is loading fine in the cart but I cant get the product to load a custom attribute ‘manufacturer’

Here is the code on the cart

$stock = Mage::getModel( 'cataloginventory/stock_item' )->loadByProduct( $_product );

$sku_code = substr( $_product->getSku(), 0, 1 );

  <span class="uk-h6">Estimated Ship by: <span class="uk-h5" style="color:#468847;"> 
  <!--estimated shipping date-->
  <?php if ($stock->getQty()==0): ?>
  <?php echo date('l jS of F Y',strtotime("+21 day")); ?>
  <?php elseif ($_product->getAttributeText('manufacturer') == "Dora"): ?>
  <?php echo date('l jS of F Y',strtotime("+14 day")); ?>
  <?php elseif ($sku_code == 'M'): ?>
  <?php echo date('l jS of F Y',strtotime("+25 day")); ?>

As you can see I have two different timesets depending on the manufacturer and sku.

your help is much appreciated.

8 – Additional attribute for menu link

How I can add iteprop="url" for each link () in main menu?

So, I need to get from

<a href="" data-drupal-link-system-path="node/114">Test</a>


<a href="" data-drupal-link-system-path="node/114" itemprop="url">Test</a>

Is it possible to do it in preprocess? I would like not to use any module for this.

xml – XSD SimpleType Element with restrictions and attribute also with restrictions

I’m trying to validate an XSD but can’t find the way to fill a simpleType element with restrictions and also with an attribute that has his own restrictions too.

**<xs:element name="anio">
                <xs:restriction base="xs:integer">
                    <xs:pattern value="[1-9][0-9][0-9][0-9]"/>
                <xs:extension base="xs:integer">
                    <xs:attribute name="mes">
                            <xs:restriction base="xs:string">
                                <xs:enumeration value="enero"/>
                                <xs:enumeration value="febrero"/>
                                <xs:enumeration value="marzo"/>
                                <xs:enumeration value="abril"/>
                                <xs:enumeration value="mayo"/>
                                <xs:enumeration value="junio"/>
                                <xs:enumeration value="julio"/>
                                <xs:enumeration value="agosto"/>
                                <xs:enumeration value="septiembre"/>
                                <xs:enumeration value="octubre"/>
                                <xs:enumeration value="noviembre"/>
                                <xs:enumeration value="diciembre"/>

s4s-elt-invalid-content.1: El contenido de ‘#AnonType_anio’ no es válido. El elemento ‘extension’ no es válido, está mal situado o aparece con demasiada frecuencia. [112]

magento2 – Custom category Image attribute magento 2.3+

I’ve searched alot and evrywhere the code has to go through many plugins and need of adding routers to add custom image attribute for category. I’ve added a code below to add custom image attribute which is completely hassel-free and hope it helps someone.

Note: It’s tested and verified on Magento 2.3.5

Considering the module exists already

  1. Add image attribute install code to setup




namespace VendorModuleSetup;

use MagentoEavSetupEavSetup;
use MagentoEavSetupEavSetupFactory;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;

class InstallData implements InstallDataInterface

    private $eavSetupFactory;

     * Constructor
     * @param MagentoEavSetupEavSetupFactory $eavSetupFactory
    public function __construct(EavSetupFactory $eavSetupFactory)
        $this->eavSetupFactory = $eavSetupFactory;

     * {@inheritdoc}
    public function install(
        ModuleDataSetupInterface $setup,
        ModuleContextInterface $context
    ) {
        $eavSetup = $this->eavSetupFactory->create(('setup' => $setup));

                'type' => 'varchar',
                'label' => 'Navigation Thumbail Image',
                'input' => 'image',
                'sort_order' => 10,
                'source' => '',
                'global' => 0,
                'visible' => true,
                'required' => false,
                'user_defined' => false,
                'default' => null,
                'group' => 'General Information',
                'backend' => 'MagentoCatalogModelCategoryAttributeBackendImage'

  1. To show custom image attribute on admin category form


<?xml version="1.0" ?>
<form xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="general" sortOrder="10">
        <field name="custom_image" sortOrder="10" formElement="imageUploader">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">category</item>
                <label translate="true">Custom Image</label>
                            <param xsi:type="url" name="url" path="catalog/category_image/upload"/>
                        <openDialogTitle>Media Gallery</openDialogTitle>
                        <allowedExtensions>jpg jpeg gif png</allowedExtensions>

That’s it. run upgrade php bin/magento setup:upgrade and clear cache php bin/magento cache:flush. The newly added category image attrribute would show as shown below.

enter image description here


python – django object has no attribute status_code

I am learning to develop and trying to develop a screen in django 1.1 and I am getting this error below. I already took a look at some stacks I already looked at httpresponse, however, I was not successful
could someone help me and explain what could be wrong?

I’m getting this error on the console:

Internal Server Error: /gerencia-margem/list
Traceback (most recent call last):
File "/home/murilo/virtualenv/intranet_erp/local/lib/python2.7/site-packages/django/core/handlers/", line 131, in get_response
response = middleware_method(request, response)
File "/home/murilo/virtualenv/intranet_erp/local/lib/python2.7/site-packages/django/middleware/", line 38, in process_response
if (response.status_code == 404 and not language_from_path and
AttributeError: 'HistoricoComissao' object has no attribute 'status_code'
(18/Nov/2020 13:30:06) "GET /gerencia-margem/list HTTP/1.1" 500 77145

This is models,

# -*- coding: utf-8 -*-
from django.db import models

class HistoricoComissao(models.Model):
class Meta:
    verbose_name = u'Historico Comissão'
    verbose_name_plural = u'Historico Comissões'

pednum = models.CharField(max_length=40, blank=True)
margem = models.DecimalField(decimal_places=4, max_digits=15, null=True, blank=True) 
data = models.DateTimeField()
historico = models.TextField((u'Historico HTML'), blank=True)

status = models.PositiveSmallIntegerField(choices=((1, 'Em Aberto'),
                                                   (3, 'Pendente'),
                                                   (4, 'Finalizado'),))

def __unicode__(self):
        return str(self.pednum)

this is the views

from django.views import View
from django.shortcuts import render
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from ..models import HistoricoComissao

def listview(request):
template_name = 'comissao/margenslist.html'
comissoes = HistoricoComissao.objects.all
context = {
    'comissoes': comissoes
return render(request,template_name,context)

this is

from django.conf.urls import  url
from . import views

urlpatterns = (
    url(r'^list$', views.HistoricoComissao, name='historico_comissao'),

magento2.3 – How to show attribute before product title?

This is the attributes.phtml located in vendormagentomodule-catalogviewfrontendtemplatesproductview which shows additional attributes:

$_helper = $this->helper('MagentoCatalogHelperOutput');
$_product = $block->getProduct();
<?php if ($_additional = $block->getAdditionalData()): ?>
<div class="additional-attributes-wrapper table-wrapper">
    <table class="data table additional-attributes" id="product-attribute-specs-table">
        <caption class="table-caption"><?= /* @escapeNotVerified */ __('More Information') ?></caption>
        <?php foreach ($_additional as $_data): ?>
                <th class="col label" scope="row"><?= $block->escapeHtml($_data('label')) ?></th>
                <td class="col data" data-th="<?= $block->escapeHtml($_data('label')) ?>"><?= /* @escapeNotVerified */ $_helper->productAttribute($_product, $_data('value'), $_data('code')) ?></td>           
        <?php endforeach; ?>

I try to use this code for getting the attribute modell in the title.phtml located in appdesignfrontendCompanyVendorMagento_Themetemplateshtml but it doesn’t work:

if ($block->$_data('label') = 'modell'):

The code for title.phtml is:

<?php if ($title): ?>
<div class="page-title-wrapper<?php /* @escapeNotVerified */
echo $cssClass; ?>">
    <h1 class="page-title"
        <?php if ($block->getId()): ?> id="<?php /* @escapeNotVerified */
        echo $block->getId(); ?>" <?php endif; ?>
        <?php if ($block->getAddBaseAttributeAria()): ?>
            aria-labelledby="<?php /* @escapeNotVerified */
            echo $block->getAddBaseAttributeAria(); ?>"
        <?php endif; ?>>
        <?php /* @escapeNotVerified */

        $_helper = $this->helper('MagentoCatalogHelperOutput');
        $_product = $block->getProduct();
        if ($_additional = $block->getAdditionalData()):
            foreach ($_additional as $_data):
                if ($block->$_data('label') = 'modell'): //Tried here
                    echo $block->escapeHtml($_data('label'));
                    echo $_helper->productAttribute($_product, $_data('value'), $_data('code'));
        echo $title ?>
    <?php echo $block->getChildHtml(); ?>

How can I get this work? Thanks

magento2.3 – Get attribute admin values layered navigation filter – Magento 2.3

I need to change this code to get attribute Admin value not store view value, any advice about this, please. or how to set a store view in this code to be able to list the admin value and skipping the store views value.

public function getAttributeValue($filterItem)
        $labelValues = ();

        if (method_exists($filterItem->getFilter(), 'getAttributeValues')) {
            $values = $filterItem->getFilter()->getAttributeValues();

            if ($values) {
                foreach ($values as $optionId) {
                    $labelValues() = $filterItem->getFilter()->getAttributeModel()->getFrontend()->getOption($optionId);

        $labelValues() = $filterItem->getLabel();

        $attribute  = $filterItem->getFilter()->getData('attribute_model'); //->getAttributeCode()
        if ($attribute) {
            if ($attribute->getAttributeCode() == 'price' || $attribute->getBackendType() == 'decimal') {
                return $filterItem->getValue();

        $labelValues = array_unique($labelValues);
        return implode($this->helperLayerAll->getMultipleValueSeparator(), $labelValues);

sql server – OPENXML to get content by using element and attribute name

In this SQL Server OPENXML example:

declare @xmldata xml    

set @xmldata = 
'<?xml version="1.0"?>
<wddxPacket version="1.0">
        <var dimension="task"><string>Task 1</string></var>
        <var dimension="startdate"><string>2020-11-14</string></var>
        <var dimension="startdate"><string>2020-11-15</string></var>
        <var dimension="task"><string>Task 2</string></var>

DECLARE @hDoc int
EXEC sp_xml_preparedocument @hDoc OUTPUT, @xmldata

FROM OPENXML(@hDoc, '//wddxPacket/data',2)
            task          varchar(200) 'var(1)/string',
            startdate     varchar(200) 'var(2)/string'

EXEC sp_xml_removedocument @hDoc

This is the current output:

task         startdate
------       ----------
Task 1       2020-11-14
2020-11-15   Task 2   

But I really want this output:

task         startdate
------       ----------
Task 1       2020-11-14
Task 2       2020-11-15

To identify the content, I cannot use “var” alone, because all elements of interest are named “var”. I cannot use position (1) or (2), because the position numbers are inconsistent in the XML, resulting in the current mixed-up output. How do I identify the elements based on “var” and the “dimension” attribute names of “task” or “startdate”?

python – Should I design a class to handle my other class or the attribute of my other class?

Please allow me to illustrate my question with a simple example. Let’s suppose we have a Customer class:

class Customer:

    def __init__(self, name, surname, email): = name
        self.surname = surname = email

And we also have a Bill class that needs info from a Customer object instance. Should I write the Bill by providing a Customer object instance as an argument?

class Bill:

    def __init__(self, amount, customer):
        self.amount = amount
        self.customer = customer
    def to_txt(self):
        with open("bill.txt", "w") as file:
            file.write(f"{} due amount is {self.amount}")

customer = Customer("John", "Smith", "")
bill = Bill(100, customer)

Or should Bill simply get a name as an argument as shown below?

class Bill:

    def __init__(self, amount, period, customer):
        self.amount = amount
        self.period = period
        self.customer_name = customer_name
    def to_txt(self):
        with open("bill.txt", "w") as file:
            file.write(f"{self.customer_name} due amount is {self.amount}")

    customer = Customer("John", "Smith", "")
    bill = Bill(100,

Edit: A user dubbed this question as a duplicate, but that question is about passing attributes between different methods in the same class. My question is about passing attributes between different classes.