I hope it would be helpful for you. In below code I have used orderCollectionFactory to retrieve custom attribute value:
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollection;
* @var ...
You can use the below code or create a new file in
Then you can add below content
Get the collection in your block file
public function getOrderCollection()
$collection = $this->_orderCollectionFactory->create();
I FOUND THE SOLUTION!
This is the complete code for add to cart multiple items programmatically that i write.
I hope this help someone ;)
You can get it with $item->getProduct()->getData('attribute_code_here')
But there is a problem.
Actually a few:
Product may have been deleted
the attribute value has been changed after the order was placed.
the attribute may have been deleted
The best approach would be to save the value of the product attribute on the order item when the order is ...
You need to start emulation using this below code :
$this->appEmulation->startEnvironmentEmulation($storeId, \Magento\Framework\App\Area::AREA_FRONTEND, true);
After that, you can get product image full url in your rest api.
For more details : Click Here
Hope, It will helpful for you.
Please share your code so we can see how you create the two custom attributes.
are the two attributes different from each other? maybe one is text/select/multiselect etc.
We can't help you without the related code or specific informations.
This question has been asked before.
What is the use of 'Cost' attribute in Catalog product in magento 2
It's saved to the quote and to other documents. The (purchase)cost of an item can go up or down, Because of this, the gross margin can be calculated per product even when the order is a few months old.
I am assuming your attribute code is external_link
Now we will add an if condition for external_link code and add a tag like:
customize the code according to your requirement i have written it for one my work where i needed to export products from magento 1. i this code am just taking the sku, id , and price you can take other things as well if you want.
// output headers so that the file is downloaded rather than displayed
header('Content-Type: text/csv; charset=utf-8'...
You can use the updateAttribute function to update the existing product attribute easily with storewise also.
Here is the sample Code:
$updateAttributes['case_back'] = "Black";
$updateAttributes['case_material'] = "Silver";
$action = objectManager->create('\Magento\Catalog\Model\ResourceModel\Product\Action');
Try to remove generated/code/* and var/cache/*. Run the php bin/magento indexer:reindex and check again.
Check if the attribute configurableExi... has frontend_label value! ((Magento\Framework\View\Element\UiComponentFactory->mergeMetadataElement(Array, 'configurableExi...', NULL, false) #1) )
Check if frontend_input value of the attribute is valid and ...
If you using console command for this propose that is very fast an useful things. For console command you need to do this below code. In between you have to put the product update csv in var/upload/ folder or you select other folder.
add below code in di.xml file in app\code[Vendor][Namespace]\etc
In order to update product attribute programmatically I use below way which is much faster then to save whole object
public function __construct(
$this->productAction = $productAction;
public function saveProductAttribute()
$cnt = 0;
I have a solution working on my local environment. Before posting the full solution, I'd like to verify your requirements:
we are after something that performs faster than your solution but you do not specify whether the speed is over 1 sku, many skus or 1000..
My import has pros and cons: I do not claim it competes with Magento and it is not ready for ...
Create an Attribute in admin with text type say external_link
Add phtml at:
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/...
Then you need to do the following things.
first create one product attribute where you mention this link of third party.
Now create one custom extension and create custom phtml file and call the file on product page on specific by using reference block.
Now in that phtml file, fetch that product attribute value and show to customer.
For Minicart update, You need to add action URL in sections.xml file like below ex.
Create a sections file app/code/Vendor/Module/etc/frontend/sections.xml
I answered a similar question on this ticket, you can create a command import by using the default Magento import model.
That means you can use Magento import template CSV file like UI at System -> Data Transfer -> Import / Export
Let me know if you need a more detailed script.
I think you should fire the query directly on URL Rewrite table.
$productUrl = Mage::getResourceModel('core/url_rewrite')
->getRequestPathByIdPath('product/' . $productId, $storeId);
ou can try getting the product id as
$product = $observer->getEvent()->getProduct();
$productId = $product->getId();
Hope it was helpful.
If you look at the function \Magento\Checkout\Controller\Onepage\Success::execute, you will see the code below:
'order_ids' => [$session->getLastOrderId()],
'order' => $session->getLastRealOrder()
I have an idea for something similar but it leverages some data we already have in our system. We have an attribute on products like this that contains a set of SKUs, one of which must be selected and purchased along with the parent item.
I'm going to make a Magento 2 Bundle Product containing all of the parent and children products in their respective ...
In magento 2.3.4 i get this like this. You can get all images of the product by gallery ReadHandler
class DownloadPictures extends \Magento\Framework\App\Action\Action
public function __construct(
You can do it with n98-magerun2 if this is a one-shot task:
If you want to delete categories with IDs 1, 2, 3, 4
$cr = $di->get(\Magento\Catalog\Model\...
You want to update the attribute set for a product type:
Check out this question/answer for ...
This should do it:
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
<container name="product.info.form.content" as="product_info_form_content">
<update handle="catalog_product_opengraph" /...
cannot delete or update a parent row: a foreign key constraint fails (amasty_pgrid_qty_sold, constraint amasty_pgrid_qty_sold_ibfk_4 foreign key (product_id) references catalog_product_entity (entity_id) on delete no action on up)
we need to remove entry from amasty_pgrid_qty_sold before actual product delete from catalog_product_entity ...
its because of $product->save()
when you save product with orm, its setting has_options to 0.
Shortly its a magento bug.
To fix that issue in db level, you can execute the query below.
update catalog_product_entity t1
inner join catalog_product_option t2 on t2.product_id = t1.entity_id
set t1.has_options = 1
where t1.has_options = 0 and t1.type_id = '...