magento 2 ; only want custom product attributes to show on custom product

I created a custom virtual product that is based on a date attribute. i.e product is available on certain days a month.

However, the only attributes I want for it are name, sku, quantity, date.

I built a custom date feature but this date is now showing up on all other type of products.

question 1:

how can i ensure that the custom attributes only show on my custom virtual product.

QUESTION TWO

How can I remove all other attributes/form values like content, design etc

this is what i did to create the custom date attribute:

Test/Example/Ui/Component/DataProvider/Product/Form/Modifier/Datetime.php

public function install(ModuleDataSetupInterface $  setup, ModuleContextInterface $  context)     {         $  eavSetup = $  this->eavSetupFactory->create(['setup' => $  setup]);          $  eavSetup->addAttribute(                 \Magento\Catalog\Model\Product::ENTITY,         'dome_dates',         [             'group' => 'Custom Attribute',             'label' => 'Dome Date',             'type' => 'datetime',             'input' => 'date',             'class' => 'validate-date',             'required' => false,             'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,             'visible' => true,             'required' => false,             'user_defined' => true,             'default' => '',             'searchable' => true,             'filterable' => true,             'filterable_in_search' => true,             'visible_in_advanced_search' => true,             'comparable' => false,             'visible_on_front' => false,             'used_in_product_listing' => true,             'unique' => false         ]     );      } 

and in my Di:

 <virtualType name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool">         <arguments>             <argument name="modifiers" xsi:type="array">                 <item name="dome_dates" xsi:type="array">                     <item name="class" xsi:type="string">Test\Example\Ui\DataProvider\Product\Form\Modifier\Datetime</item>                     <item name="sortOrder" xsi:type="number">100</item>                 </item>             </argument>         </arguments>     </virtualType> 

Facing problem with custom attributes in customer address checkout

I am facing a problem adding customer address custom attributes, in Magento 2.2 is working fine but after upgrading to Magento 2.3 i am receiving this error when shipping-information is saved:

Error occurred during “shipping_address” processing. Error occurred during “customAttributes” processing. A custom attribute is specified with a missing attribute code. Verify the code and try again.

It is happening when sending shipping information, custom attributes keys are not the custom attributes labels, so when magento validate the custme attributes it’s sending the error. I dont find any different in documentation from Magento 2.2 and 2.3 about adding custom attributes.

enter image description here

Here is an example of how I am adding custom attributes

$  customFieldBetweenStreets = [         'component' => 'Magento_Ui/js/form/element/abstract',         'config' => [             // customScope is used to group elements within a single form (e.g. they can be validated separately)             'customScope' => 'shippingAddress.custom_attributes',             'customEntry' => null,             'template' => 'ui/form/field',             'elementTmpl' => 'ui/form/element/input',             'tooltip' => [                 'description' => 'Entre calles',             ],         ],         'dataScope' => 'shippingAddress.custom_attributes' . '.' . $  customAttributeCodeBetweenStreets,         'label' => 'Entre calles',         'provider' => 'checkoutProvider',         'sortOrder' => 122,         'validation' => [             'required-entry' => true,             'max_text_length' => 60         ],         'options' => [],         'filterBy' => null,         'customEntry' => null,         'visible' => true,     ]; 

And my set-shipping-information-mixin

return function (setShippingInformationAction) {     return wrapper.wrap(setShippingInformationAction, function (originalAction, messageContainer) {          var shippingAddress = quote.shippingAddress();          if (shippingAddress['extension_attributes'] === undefined) {             shippingAddress['extension_attributes'] = {};         }          if (shippingAddress.customAttributes != undefined) {             $  .each(shippingAddress.customAttributes , function( key, value ) {                  if($  .isPlainObject(value)){                     value = value['value'];                 }                  shippingAddress['customAttributes'][key] = value;                 shippingAddress['extension_attributes'][key] = value;              });         }          return originalAction(messageContainer);     }); }; 

});

Here the $ .each(shippingAddress.customAttributes , function( key, value ) Key is returning the 0,1,2,3 etc, index while in Magento 2.2 is the custom attribute code I am adding in my Layout Processor

Any help would be appreciated

Magento 2 use extension attributes in source edit form

Is there a way to populate UI dataSource with my extension attributes when editing source in (Stores->Inventory->Sources)? I have added my extension attributes to source edit form via extending UI component, now I need to populate its data. All extension_attributes are saved in my repository and are loaded when get, getList for sources is called. enter image description here

Woocommerce products with shared attributes and prices

I have a Woocommerce store with a large group of similar variable products that share the same attributes (size, material, etc.) and prices. I would like to find a method to update the former properties of the products in the group as efficiently as possible, so that changes would be applied to all the products in the group. In other words, I would like to link these products and their properties together in some way, so that so I could easily make bulk changes (e.g. change the prices) to them when necessary. Is there a way to accomplish this?

Magento 2 REST API – Get filterable attributes of a category before and after applying filter with multiselect

I am trying to achieve multiselect filter in custom script to be able to use it in custom REST API.

While I am able to get all filterable attributes specific to a category. But after applying filter through params (e.g. Size), the size attribute get removed from the filterable attribute list after apply (default magento behaviour).

Need filters to behave as multiselect. I tried to implement it using classes of some 3rd party modules but of no help.

Below is my code

<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); // Copyright 2009, FedEx Corporation. All rights reserved. // Version 12.0.0 use Magento\Framework\App\Bootstrap; /** * If your external file is in root folder */ require __DIR__ . '/app/bootstrap.php'; $  params = $  _SERVER; $  bootstrap = Bootstrap::create(BP, $  params); ini_set('display_errors', 1); $  obj = $  bootstrap->getObjectManager(); $  state = $  obj->get('Magento\Framework\App\State'); $  state->setAreaCode('frontend');  $  objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $  categoryFactory = $  objectManager->get('Magento\Catalog\Model\CategoryFactory'); $  storeManager = $  objectManager->get('Magento\Store\Model\StoreManagerInterface'); $  resource = $  objectManager->get('Magento\Framework\App\ResourceConnection'); $  request = $  objectManager->get('Magento\Framework\App\Request\Http'); $  params = $  request->getParams(); $  connection = $  resource->getConnection(); $  storeId = $  storeManager->getStore()->getId(); $  categoryId = 824;  $  category = $  categoryFactory->create()->setStoreId($  storeId)->load($  categoryId); $  storeManager->setCurrentStore($  storeId);  $  filterableAttributes = $  objectManager->get(\Magento\Catalog\Model\Layer\Category\FilterableAttributeList::class); $  appState = $  objectManager->get(\Magento\Framework\App\State::class); $  layerResolver = $  objectManager->get(\Magento\Catalog\Model\Layer\Resolver::class); $  filterList = $  objectManager->create(     \Magento\Catalog\Model\Layer\FilterList::class,     [         'filterableAttributes' => $  filterableAttributes     ] );  $  layer = $  layerResolver->get(); $  layer->setCurrentCategory($  category); $  allFilters = $  filterList->getFilters($  layer);  $  beforefinalFilters = []; foreach ($  allFilters as $  filter) {     if ($  filter->getName() != 'Category' && $  filter->getName() != 'Price'){         if ($  filter->getItemsCount()) {             $  output = [];             foreach ($  filter->getItems() as $  item) {                 if($  item->getFilter()->getData("attribute_model")){                     $  flag = false;                     $  code = $  item->getName();                     $  name = strip_tags($  item->getLabel());                      $  beforefinalFilters[$  code][] = array(                                                'name'=> $  name,                         'value'=> $  item->getValue(),                         'code'=> $  item->getFilter()->getAttributeModel()->getAttributeCode(),                         'isActive' => $  flag                     );                 }             }         }     } }  echo "Before filter: \n"; echo "<pre>"; print_r($  beforefinalFilters); echo "</pre>"; echo "----------------------------------------------------------------------------------"; echo "<br>";  $  appliedFilters = array(); foreach ($  allFilters as $  filter) {     if ($  filter->getName() != 'Category' && $  filter->getName() != 'Price' && $  filter->getItemsCount() && isset($  params[$  filter->getAttributeModel()->getAttributeCode()])) {         $  appliedFilters[$  filter->getAttributeModel()->getAttributeCode()]['label'] = $  filter->getAttributeModel()->getFrontendLabel();         $  appliedFilters[$  filter->getAttributeModel()->getAttributeCode()]['value'] = isset($  params[$  filter->getAttributeModel()->getAttributeCode()])?$  params[$  filter->getAttributeModel()->getAttributeCode()]:'';         $  appliedFilters[$  filter->getAttributeModel()->getAttributeCode()]['filter'] = $  filter;         $  request->setParam($  filter->getAttributeModel()->getAttributeCode(), $  params[$  filter->getAttributeModel()->getAttributeCode()]);     } }  foreach ($  appliedFilters as $  key => $  value) {     $  filter = $  value['filter'];     $  filterValue = $  value['value'];     if($  key == 'price' || $  key == 'category'){         continue;     }else{         //apply filter         //Magento\Catalog\Model\Layer\Filter\Attribute         $  filter->apply($  request);     } }  $  collection = $  layer->getProductCollection(); $  collection->getSelect()->group('e.entity_id');   //get filters after applying $  allFiltersAfter = $  filterList->getFilters($  layer);  $  afterfinalFilters = []; foreach ($  allFiltersAfter as $  filter) {     if ($  filter->getName() != 'Category' && $  filter->getName() != 'Price'){         if ($  filter->getItemsCount()) {             $  output = [];             foreach ($  filter->getItems() as $  item) {                 if($  item->getFilter()->getData("attribute_model")){                     $  flag = false;                     $  code = $  item->getName();                     $  name = strip_tags($  item->getLabel());                     $  afterfinalFilters[$  code][] = array(                                                 'name'=> $  name,                         'value'=> $  item->getValue(),                         'code'=> $  item->getFilter()->getAttributeModel()->getAttributeCode(),                         'isActive' => $  flag                     );                 }             }         }     } }  echo "\n After filter: \n"; echo "<pre>"; print_r($  afterfinalFilters); echo "</pre>"; 

Terminology: Difference between decision variables, features and attributes?

Could there be a difference between the words “feature”, “attribute”, and “decision variable” when used in the same paper? The one I am specifically thinking about is about an optimization method for clustering, but I am also wondering if there generally are any scenarios for which it could be.

I can’t manage to google up an answer that either confirms or denies that these are the same thing, and I have no formal training in data science.

Search is not working by product attributes

We have added couple of products on our Magento 2 site. In the home page of the site, we have a search form and there we have put input boxes as product name, from, to and location. We want to display the results as per the selected criteria in the form but its not working as expected.

Code:

<dd id="construction" class="item content active" data-role="content" >                      <form method="GET" action="<?php echo $  block->getUrl('catalogsearch/result/');?>">                         <fieldset class="search-forms-fieldset" id="date-range-1">                         <legend class="legend"><span><?= /* @escapeNotVerified */ __('Search Settings') ?></span></legend>                          <div class="field region">                             <label for="select" class="label"><span>Select</span></label>                              <div class="control" id="conselect">                                 <input type="text" name="q" placeholder="<?= /* @escapeNotVerified */ __('What are you looking for?') ?>" />                                 <?php /*?><select name="looking" id="looking">                                     <option value="">Please select</option>                                     <option value="5">5</option>                                     <option value="10">10</option>                                     <option value="15">15</option>                                     <option value="20">20</option>                                 </select><?php */?>                             </div>                         </div>                         <div class="field">                             <label for="location" class="label"><span><?= /* @escapeNotVerified */ __('Location') ?></span></label>                              <div class="control" id="conlocation">                                 <input type="text" name="location" placeholder="<?= /* @escapeNotVerified */ __('Location') ?>" />                             </div>                         </div>                          <div class="field">                             <label for="available_from" class="label"><span><?= /* @escapeNotVerified */ __('Available From') ?></span></label>                              <div class="control" id="confrom">                                 <input type="text" name="available_from" placeholder="<?= /* @escapeNotVerified */ __('Available From') ?>" id="date-from-1" />                             </div>                         </div>                         <div class="field">                             <label for="available_to" class="label"><span><?= /* @escapeNotVerified */ __('Location') ?></span></label>                              <div class="control" id="conto">                                 <input type="text" name="available_to" placeholder="<?= /* @escapeNotVerified */ __('Available To') ?>" id="date-to-1"/>                             </div>                           </div>                          </fieldset>                         <div class="actions-toolbar">                           <div class="primary">                             <button type="submit"                                     class="action search primary"                                     title="<?= $  block->escapeHtml(__('Search')) ?>">                                 <span><?= /* @escapeNotVerified */ __('Search') ?></span>                             </button>                           </div>                         </div>                       </form>                  </dd> 

Please see the below screenshot for your reference:

enter image description here

Add custom attributes when creating product via REST API

I am attempting to set custom attributes when creating a new product via the REST API. The products have a required attribute hpUuid. This is part of my JSON file to create the new product:

{     "product": {         "sku": "12345",          ... Quite a few fields here ...          "custom_attributes": [             {                 "attribute_code": "hpUuid",                 "value": "123"             }         ],     } } 

When submitting, the REST API returns this error:

{"message":"The \"hpUuid\" attribute value is empty. Set the attribute and try again."} 

The fine docs suggest that the format is correct, but why can it not read the value?

Proper Use Of HTML Data Attributes

I’m writing several JavaScript plugins that are run automatically when the proper HTML markup is detected on the page. For example, when a tabs class is detected, the tabs plugin is loaded dynamically and it automatically applies the tab functionality. Any customization options for the JavaScript plugin are set via HTML5 data attributes, very similar to what Twitter’s Bootstrap Framework does.

The appeal to the above system is that, once you have it working, you don’t have worry about manually instantiating plugins, you just write your HTML markup. This is especially nice if people who don’t know JavaScript well (or at all) want to make use of your plugins, which is one of my goals.

This setup has been working very well, but for some plugins, I’m finding that I need a more robust set of options. My choices seem to be having an element with many data-attributes or allowing for a single data-options attribute with a JSON options object as a value. Having a lot of attributes seems clunky and repetitive, but going the JSON route makes it slightly more complicated for novices and I’d like to avoid full-blown JavaScript in the attributes if I can. I’m not entirely sure which way is best.

  1. Is there a third option that I’m not considering?
  2. Are there any recommended best practices for this particular use case?

php code or mysql query to ‘bundle’ 2 attributes into 1

I would like to know if it’s possible to update a text attribute by appending the content of another text attribute. i.e. For all my products, I would like that the new content of attribute1 becomes the content of attribute1 + the content of attribute2. I already know the attribute_id values (obviously) from the eav_attribute table. I know that the attributes are stored in the catalog_product_entity_text table. Thank you for your help 🙂